1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINES_TEST_UTIL_H_
#define COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINES_TEST_UTIL_H_
#include <memory>
#include <string>
#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
struct TemplateURLData;
namespace sync_preferences {
class TestingPrefServiceSyncable;
}
// Generates a TemplateURLData structure useful for tests filled with values
// autogenerated from |provider_name|.
std::unique_ptr<TemplateURLData> GenerateDummyTemplateURLData(
const std::string& keyword);
// Checks that the two TemplateURLs are similar. Does not check the id, the
// date_created or the last_modified time. Neither pointer should be null.
void ExpectSimilar(const TemplateURLData* expected,
const TemplateURLData* actual);
// Writes default search engine |extension_data| into the extension-controlled
// preference in |prefs|.
void SetExtensionDefaultSearchInPrefs(
sync_preferences::TestingPrefServiceSyncable* prefs,
const TemplateURLData& extension_data);
// Removes the extension-controlled default search engine preference from
// |prefs|.
void RemoveExtensionDefaultSearchFromPrefs(
sync_preferences::TestingPrefServiceSyncable* prefs);
class FakeSearchEngineChoiceServiceClient
: public search_engines::SearchEngineChoiceService::Client {
public:
explicit FakeSearchEngineChoiceServiceClient(
country_codes::CountryId variations_country = country_codes::CountryId(),
bool is_profile_eligible_for_dse_guest_propagation = false,
bool is_device_restore_detected_in_current_session = false,
bool does_choice_predate_device_restore = false);
~FakeSearchEngineChoiceServiceClient() override;
// `SearchEngineChoiceService::Client` implementation.
country_codes::CountryId GetVariationsCountry() override;
bool IsProfileEligibleForDseGuestPropagation() override;
bool IsDeviceRestoreDetectedInCurrentSession() override;
bool DoesChoicePredateDeviceRestore(
const search_engines::ChoiceCompletionMetadata& choice_metadata) override;
void set_variations_country(country_codes::CountryId variations_country) {
variations_country_ = variations_country;
}
void set_is_profile_eligible_for_dse_guest_propagation(bool eligible) {
is_profile_eligible_for_dse_guest_propagation_ = eligible;
}
void set_is_device_restore_detected_in_current_session(bool is_detected) {
is_device_restore_detected_in_current_session_ = is_detected;
}
void set_does_choice_predate_device_restore(bool does_predate) {
does_choice_predate_device_restore_ = does_predate;
}
private:
country_codes::CountryId variations_country_;
bool is_profile_eligible_for_dse_guest_propagation_ = false;
bool is_device_restore_detected_in_current_session_ = false;
bool does_choice_predate_device_restore_ = false;
};
#endif // COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINES_TEST_UTIL_H_
|