#include "components/optimization_guide/core/optimization_guide_store.h"
#include <optional>
#include <string>
#include <vector>
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/leveldb_proto/testing/fake_db.h"
#include "components/optimization_guide/core/model_util.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/optimization_guide_prefs.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "components/optimization_guide/core/store_update_data.h"
#include "components/optimization_guide/proto/hint_cache.pb.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
FakeDB;
Mock;
namespace optimization_guide {
namespace {
constexpr char kDefaultComponentVersion[] = …;
constexpr char kUpdateComponentVersion[] = …;
std::string GetHost(size_t id) { … }
enum class MetadataSchemaState { … };
}
class OptimizationGuideStoreTest : public testing::Test { … };
TEST_F(OptimizationGuideStoreTest, NoInitialization) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeFailedOnInitializeWithNoInitialData) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeFailedOnLoadMetadataWithNoInitialData) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeFailedOnUpdateMetadataNoInitialData) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeFailedOnInitializeWithInitialData) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeFailedOnLoadMetadataWithInitialData) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeFailedOnUpdateMetadataWithInvalidSchemaEntry) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeFailedOnLoadHintEntryKeysWithInitialData) { … }
TEST_F(OptimizationGuideStoreTest, InitializeSucceededWithoutSchemaEntry) { … }
TEST_F(OptimizationGuideStoreTest, InitializeSucceededWithInvalidSchemaEntry) { … }
TEST_F(OptimizationGuideStoreTest, InitializeSucceededWithValidSchemaEntry) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeSucceededWithInvalidSchemaEntryAndInitialData) { … }
TEST_F(OptimizationGuideStoreTest, InitializeSucceededWithPurgeExistingData) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeSucceededWithValidSchemaEntryAndInitialData) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeSucceededWithValidSchemaEntryAndComponentDataOnly) { … }
TEST_F(OptimizationGuideStoreTest,
InitializeSucceededWithValidSchemaEntryAndFetchedMetaData) { … }
TEST_F(OptimizationGuideStoreTest,
CreateComponentUpdateDataFailsForUninitializedStore) { … }
TEST_F(OptimizationGuideStoreTest,
CreateComponentUpdateDataFailsForEarlierVersion) { … }
TEST_F(OptimizationGuideStoreTest,
CreateComponentUpdateDataFailsForCurrentVersion) { … }
TEST_F(OptimizationGuideStoreTest,
CreateComponentUpdateDataSucceedsWithNoPreexistingVersion) { … }
TEST_F(OptimizationGuideStoreTest,
CreateComponentUpdateDataSucceedsForNewerVersion) { … }
TEST_F(OptimizationGuideStoreTest, UpdateComponentHintsUpdateEntriesFails) { … }
TEST_F(OptimizationGuideStoreTest, UpdateComponentHintsGetKeysFails) { … }
TEST_F(OptimizationGuideStoreTest, UpdateComponentHints) { … }
TEST_F(OptimizationGuideStoreTest,
UpdateComponentHintsAfterInitializationDataPurge) { … }
TEST_F(OptimizationGuideStoreTest,
CreateComponentDataWithAlreadyUpdatedVersionFails) { … }
TEST_F(OptimizationGuideStoreTest,
UpdateComponentHintsWithUpdatedVersionFails) { … }
TEST_F(OptimizationGuideStoreTest, LoadHintOnUnavailableStore) { … }
TEST_F(OptimizationGuideStoreTest, LoadHintFailure) { … }
TEST_F(OptimizationGuideStoreTest, LoadHintSuccessInitialData) { … }
TEST_F(OptimizationGuideStoreTest, LoadHintSuccessUpdateData) { … }
TEST_F(OptimizationGuideStoreTest, FindHintEntryKeyOnUnavailableStore) { … }
TEST_F(OptimizationGuideStoreTest, FindHintEntryKeyInitialData) { … }
TEST_F(OptimizationGuideStoreTest, FindHintEntryKeyUpdateData) { … }
TEST_F(OptimizationGuideStoreTest, FetchedHintsMetadataStored) { … }
TEST_F(OptimizationGuideStoreTest, FindHintEntryKeyForFetchedHints) { … }
TEST_F(OptimizationGuideStoreTest,
FindHintEntryKeyCheckFetchedBeforeComponentHints) { … }
TEST_F(OptimizationGuideStoreTest, SuccessfulRemovedFetchedHintsByKey) { … }
TEST_F(OptimizationGuideStoreTest, FailedRemovedFetchedHintsByKey) { … }
TEST_F(OptimizationGuideStoreTest, ClearFetchedHints) { … }
TEST_F(OptimizationGuideStoreTest, FetchHintsPurgeExpiredFetchedHints) { … }
TEST_F(OptimizationGuideStoreTest, FetchedHintsLoadExpiredHint) { … }
TEST_F(OptimizationGuideStoreTest, FetchedHintsLoadPopulatesExpiryTime) { … }
}