Commit b38b39e2 authored by Catherine Chung's avatar Catherine Chung Committed by Commit Bot

Create test FeatureEngagementTracker component

Provides a test FeatureEngagementTracker that makes all non-relevant conditions
true so you can test per-feature specific conditions/configurations.

Bug: 734132
Change-Id: I83e6f0be55870ae1eb812d0688d0cb416672ab3f
Reviewed-on: https://chromium-review.googlesource.com/570509
Commit-Queue: Catherine Chung <catherinechung@google.com>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487923}
parent 0e9b7a67
...@@ -22,6 +22,9 @@ group("unit_tests") { ...@@ -22,6 +22,9 @@ group("unit_tests") {
deps = [ deps = [
"//components/feature_engagement_tracker/internal:unit_tests", "//components/feature_engagement_tracker/internal:unit_tests",
# TODO(crbug.com/744694 - following line will soon be removed)
"//components/feature_engagement_tracker/test:test_support",
] ]
data_deps = [ data_deps = [
......
...@@ -11,6 +11,7 @@ static_library("internal") { ...@@ -11,6 +11,7 @@ static_library("internal") {
visibility = [ visibility = [
":*", ":*",
"//components/feature_engagement_tracker", "//components/feature_engagement_tracker",
"//components/feature_engagement_tracker/test:test_support",
] ]
sources = [ sources = [
......
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("test_support") {
testonly = true
sources = [
"test_feature_engagement_tracker.cc",
"test_feature_engagement_tracker.h",
]
deps = [
"//base",
"//components/feature_engagement_tracker/internal",
"//components/feature_engagement_tracker/public",
]
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/feature_engagement_tracker/test/test_feature_engagement_tracker.h"
#include "base/memory/ptr_util.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "components/feature_engagement_tracker/internal/chrome_variations_configuration.h"
#include "components/feature_engagement_tracker/internal/feature_config_condition_validator.h"
#include "components/feature_engagement_tracker/internal/feature_config_storage_validator.h"
#include "components/feature_engagement_tracker/internal/feature_engagement_tracker_impl.h"
#include "components/feature_engagement_tracker/internal/in_memory_store.h"
#include "components/feature_engagement_tracker/internal/init_aware_model.h"
#include "components/feature_engagement_tracker/internal/model_impl.h"
#include "components/feature_engagement_tracker/internal/never_availability_model.h"
#include "components/feature_engagement_tracker/internal/system_time_provider.h"
#include "components/feature_engagement_tracker/public/feature_engagement_tracker.h"
#include "components/feature_engagement_tracker/public/feature_list.h"
namespace feature_engagement_tracker {
// static
std::unique_ptr<FeatureEngagementTracker> CreateTestFeatureEngagementTracker() {
auto configuration = base::MakeUnique<ChromeVariationsConfiguration>();
configuration->ParseFeatureConfigs(GetAllFeatures());
auto storage_validator = base::MakeUnique<FeatureConfigStorageValidator>();
storage_validator->InitializeFeatures(GetAllFeatures(), *configuration);
auto raw_model = base::MakeUnique<ModelImpl>(
base::MakeUnique<InMemoryStore>(), std::move(storage_validator));
auto model = base::MakeUnique<InitAwareModel>(std::move(raw_model));
return base::MakeUnique<FeatureEngagementTrackerImpl>(
std::move(model), base::MakeUnique<NeverAvailabilityModel>(),
std::move(configuration),
base::MakeUnique<FeatureConfigConditionValidator>(),
base::MakeUnique<SystemTimeProvider>());
}
} // namespace feature_engagement_tracker
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_TEST_TEST_FEATURE_ENGAGEMENT_TRACKER_H_
#define COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_TEST_TEST_FEATURE_ENGAGEMENT_TRACKER_H_
#include <memory>
namespace feature_engagement_tracker {
class FeatureEngagementTracker;
// Provides a test FeatureEngagementTracker that makes all non-relevant
// conditions true so you can test per-feature specific configurations.
// Note: Your feature config params must have |"availability": "ANY"|
// or the FeatureConfigConditionValidator will return false.
std::unique_ptr<FeatureEngagementTracker> CreateTestFeatureEngagementTracker();
} // namespace feature_engagement_tracker
#endif // COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_TEST_TEST_FEATURE_ENGAGEMENT_TRACKER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment