OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/translate/core/browser/translate_ranker_impl.h" | 5 #include "components/translate/core/browser/translate_ranker_impl.h" |
6 | 6 |
7 #include <initializer_list> | 7 #include <initializer_list> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/message_loop/message_loop.h" | |
13 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
14 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
15 #include "base/task_scheduler/post_task.h" | 14 #include "base/task_scheduler/post_task.h" |
16 #include "base/test/scoped_feature_list.h" | 15 #include "base/test/scoped_feature_list.h" |
17 #include "base/test/scoped_task_scheduler.h" | 16 #include "base/test/scoped_task_environment.h" |
18 #include "components/metrics/proto/translate_event.pb.h" | 17 #include "components/metrics/proto/translate_event.pb.h" |
19 #include "components/metrics/proto/ukm/source.pb.h" | 18 #include "components/metrics/proto/ukm/source.pb.h" |
20 #include "components/prefs/scoped_user_pref_update.h" | 19 #include "components/prefs/scoped_user_pref_update.h" |
21 #include "components/sync_preferences/testing_pref_service_syncable.h" | 20 #include "components/sync_preferences/testing_pref_service_syncable.h" |
22 #include "components/translate/core/browser/proto/ranker_model.pb.h" | 21 #include "components/translate/core/browser/proto/ranker_model.pb.h" |
23 #include "components/translate/core/browser/proto/translate_ranker_model.pb.h" | 22 #include "components/translate/core/browser/proto/translate_ranker_model.pb.h" |
24 #include "components/translate/core/browser/ranker_model.h" | 23 #include "components/translate/core/browser/ranker_model.h" |
25 #include "components/translate/core/browser/translate_download_manager.h" | 24 #include "components/translate/core/browser/translate_download_manager.h" |
26 #include "components/translate/core/browser/translate_prefs.h" | 25 #include "components/translate/core/browser/translate_prefs.h" |
27 #include "components/ukm/test_ukm_service.h" | 26 #include "components/ukm/test_ukm_service.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 private: | 89 private: |
91 ukm::UkmServiceTestingHarness ukm_service_test_harness_; | 90 ukm::UkmServiceTestingHarness ukm_service_test_harness_; |
92 | 91 |
93 // Override the default URL fetcher to return custom responses for tests. | 92 // Override the default URL fetcher to return custom responses for tests. |
94 net::TestURLFetcherFactory url_fetcher_factory_; | 93 net::TestURLFetcherFactory url_fetcher_factory_; |
95 | 94 |
96 // Used to initialize the translate download manager. | 95 // Used to initialize the translate download manager. |
97 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 96 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
98 | 97 |
99 // Sets up the task scheduling/task-runner environment for each test. | 98 // Sets up the task scheduling/task-runner environment for each test. |
100 base::test::ScopedTaskScheduler scoped_task_scheduler_; | 99 base::test::ScopedTaskEnvironment scoped_task_environment_; |
101 | 100 |
102 // Manages the enabling/disabling of features within the scope of a test. | 101 // Manages the enabling/disabling of features within the scope of a test. |
103 base::test::ScopedFeatureList scoped_feature_list_; | 102 base::test::ScopedFeatureList scoped_feature_list_; |
104 | 103 |
105 // Cache and reset the application locale for each test. | 104 // Cache and reset the application locale for each test. |
106 std::string locale_; | 105 std::string locale_; |
107 | 106 |
108 DISALLOW_COPY_AND_ASSIGN(TranslateRankerImplTest); | 107 DISALLOW_COPY_AND_ASSIGN(TranslateRankerImplTest); |
109 }; | 108 }; |
110 | 109 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 EXPECT_TRUE(ranker->ShouldOverrideDecision(2, GURL(), &tep)); | 444 EXPECT_TRUE(ranker->ShouldOverrideDecision(2, GURL(), &tep)); |
446 | 445 |
447 std::vector<metrics::TranslateEventProto> flushed_events; | 446 std::vector<metrics::TranslateEventProto> flushed_events; |
448 ranker->FlushTranslateEvents(&flushed_events); | 447 ranker->FlushTranslateEvents(&flushed_events); |
449 EXPECT_EQ(0U, flushed_events.size()); | 448 EXPECT_EQ(0U, flushed_events.size()); |
450 ASSERT_EQ(2, tep.decision_overrides_size()); | 449 ASSERT_EQ(2, tep.decision_overrides_size()); |
451 ASSERT_EQ(1, tep.decision_overrides(0)); | 450 ASSERT_EQ(1, tep.decision_overrides(0)); |
452 ASSERT_EQ(2, tep.decision_overrides(1)); | 451 ASSERT_EQ(2, tep.decision_overrides(1)); |
453 ASSERT_EQ(0, tep.event_type()); | 452 ASSERT_EQ(0, tep.event_type()); |
454 } | 453 } |
OLD | NEW |