chromium/components/search/start_suggest_service_unittest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/search/start_suggest_service.h"

#include "base/functional/callback_helpers.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "components/omnibox/browser/test_scheme_classifier.h"
#include "components/search/search.h"
#include "components/search/search_provider_observer.h"
#include "components/search_engines/search_engines_test_environment.h"
#include "components/search_engines/template_url_service.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

std::string GoodServerResponse() {}

std::string GoodServerResponse2() {}

std::string BadServerResponse() {}

}  // namespace

class MockSearchProviderObserver : public SearchProviderObserver {};

class TestStartSuggestService : public StartSuggestService {};

class StartSuggestServiceTest : public ::testing::Test {};

// Test that, upon receiving a valid response, the service returns the
// suggestions as expected. In addition, when the default search engine changes
// away from Google, tests that the service does not return anything.
TEST_F(StartSuggestServiceTest,
       HandleBasicValidResponseAndClearWhenChangeDefaultSearchEngine) {}

// Test that the service synchronously returns cached fetched suggestions
// upon a subsequent FetchSuggestions() call.
TEST_F(StartSuggestServiceTest, TestReturnSavedSuggestions) {}

// Tests that explicitly setting fetch_from_server to true bypasses any cache
// and sends a request.
TEST_F(StartSuggestServiceTest, TestFetchFromServerSet) {}

// Test that the service returns an empty list in response to bad JSON returned.
TEST_F(StartSuggestServiceTest, TestBadResponseReturnsNothing) {}