OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_manager.h" | 5 #include "components/translate/core/browser/translate_manager.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
10 #include "base/test/scoped_feature_list.h" | 10 #include "base/test/scoped_feature_list.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "components/infobars/core/infobar.h" | 12 #include "components/infobars/core/infobar.h" |
13 #include "components/pref_registry/pref_registry_syncable.h" | 13 #include "components/pref_registry/pref_registry_syncable.h" |
14 #include "components/pref_registry/testing_pref_service_syncable.h" | 14 #include "components/sync_preferences/testing_pref_service_syncable.h" |
15 #include "components/translate/core/browser/mock_translate_driver.h" | 15 #include "components/translate/core/browser/mock_translate_driver.h" |
16 #include "components/translate/core/browser/translate_browser_metrics.h" | 16 #include "components/translate/core/browser/translate_browser_metrics.h" |
17 #include "components/translate/core/browser/translate_client.h" | 17 #include "components/translate/core/browser/translate_client.h" |
18 #include "components/translate/core/browser/translate_download_manager.h" | 18 #include "components/translate/core/browser/translate_download_manager.h" |
19 #include "components/translate/core/browser/translate_prefs.h" | 19 #include "components/translate/core/browser/translate_prefs.h" |
20 #include "components/translate/core/common/translate_pref_names.h" | 20 #include "components/translate/core/common/translate_pref_names.h" |
21 #include "components/variations/variations_associated_data.h" | 21 #include "components/variations/variations_associated_data.h" |
22 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 // Functions to help TEST_F in subclass to access private functions in | 215 // Functions to help TEST_F in subclass to access private functions in |
216 // TranslteManager so we can unit test them. | 216 // TranslteManager so we can unit test them. |
217 std::string CallGetTargetLanguageFromULP() { | 217 std::string CallGetTargetLanguageFromULP() { |
218 return TranslateManager::GetTargetLanguageFromULP(&translate_prefs_); | 218 return TranslateManager::GetTargetLanguageFromULP(&translate_prefs_); |
219 } | 219 } |
220 bool CallLanguageInULP(const std::string& language) { | 220 bool CallLanguageInULP(const std::string& language) { |
221 return translate_manager_->LanguageInULP(language); | 221 return translate_manager_->LanguageInULP(language); |
222 } | 222 } |
223 | 223 |
224 user_prefs::TestingPrefServiceSyncable prefs_; | 224 sync_preferences::TestingPrefServiceSyncable prefs_; |
225 | 225 |
226 // TODO(groby): request TranslatePrefs from |mock_translate_client_| instead. | 226 // TODO(groby): request TranslatePrefs from |mock_translate_client_| instead. |
227 TranslatePrefs translate_prefs_; | 227 TranslatePrefs translate_prefs_; |
228 TranslateDownloadManager* manager_; | 228 TranslateDownloadManager* manager_; |
229 | 229 |
230 TestNetworkChangeNotifier network_notifier_; | 230 TestNetworkChangeNotifier network_notifier_; |
231 translate::testing::MockTranslateDriver driver_; | 231 translate::testing::MockTranslateDriver driver_; |
232 ::testing::NiceMock<MockTranslateClient> mock_translate_client_; | 232 ::testing::NiceMock<MockTranslateClient> mock_translate_client_; |
233 std::unique_ptr<TranslateManager> translate_manager_; | 233 std::unique_ptr<TranslateManager> translate_manager_; |
234 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 234 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 // 0.79 and lower than 0.8 and the probability threshold is lower than both | 444 // 0.79 and lower than 0.8 and the probability threshold is lower than both |
445 // the one with "fr" (0.6) and "pt-PT" (0.4). | 445 // the one with "fr" (0.6) and "pt-PT" (0.4). |
446 EXPECT_TRUE(CallLanguageInULP("fr")); | 446 EXPECT_TRUE(CallLanguageInULP("fr")); |
447 EXPECT_TRUE(CallLanguageInULP("pt")); | 447 EXPECT_TRUE(CallLanguageInULP("pt")); |
448 EXPECT_FALSE(CallLanguageInULP("zh-TW")); | 448 EXPECT_FALSE(CallLanguageInULP("zh-TW")); |
449 } | 449 } |
450 | 450 |
451 } // namespace testing | 451 } // namespace testing |
452 | 452 |
453 } // namespace translate | 453 } // namespace translate |
OLD | NEW |