Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: components/translate/core/browser/translate_ui_delegate_unittest.cc

Issue 2562733003: Remove duplicated user_prefs::TestingPrefServiceSyncable (Closed)
Patch Set: Fixed usage from .mm files Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/translate/core/browser/translate_ranker_unittest.cc ('k') | extensions/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_ui_delegate.h" 5 #include "components/translate/core/browser/translate_ui_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "components/infobars/core/infobar.h" 13 #include "components/infobars/core/infobar.h"
14 #include "components/pref_registry/pref_registry_syncable.h" 14 #include "components/pref_registry/pref_registry_syncable.h"
15 #include "components/pref_registry/testing_pref_service_syncable.h" 15 #include "components/sync_preferences/testing_pref_service_syncable.h"
16 #include "components/translate/core/browser/mock_translate_driver.h" 16 #include "components/translate/core/browser/mock_translate_driver.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_infobar_delegate.h" 18 #include "components/translate/core/browser/translate_infobar_delegate.h"
19 #include "components/translate/core/browser/translate_manager.h" 19 #include "components/translate/core/browser/translate_manager.h"
20 #include "components/translate/core/browser/translate_prefs.h" 20 #include "components/translate/core/browser/translate_prefs.h"
21 #include "components/variations/variations_associated_data.h" 21 #include "components/variations/variations_associated_data.h"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 private: 70 private:
71 TranslateDriver* driver_; 71 TranslateDriver* driver_;
72 PrefService* prefs_; 72 PrefService* prefs_;
73 }; 73 };
74 74
75 class TranslateUIDelegateTest : public ::testing::Test { 75 class TranslateUIDelegateTest : public ::testing::Test {
76 public: 76 public:
77 TranslateUIDelegateTest() : ::testing::Test() {} 77 TranslateUIDelegateTest() : ::testing::Test() {}
78 78
79 void SetUp() override { 79 void SetUp() override {
80 pref_service_.reset(new user_prefs::TestingPrefServiceSyncable()); 80 pref_service_.reset(new sync_preferences::TestingPrefServiceSyncable());
81 pref_service_->registry()->RegisterStringPref( 81 pref_service_->registry()->RegisterStringPref(
82 "settings.language.preferred_languages", std::string()); 82 "settings.language.preferred_languages", std::string());
83 pref_service_->registry()->RegisterStringPref("intl.accept_languages", 83 pref_service_->registry()->RegisterStringPref("intl.accept_languages",
84 std::string()); 84 std::string());
85 TranslatePrefs::RegisterProfilePrefs(pref_service_->registry()); 85 TranslatePrefs::RegisterProfilePrefs(pref_service_->registry());
86 86
87 client_.reset(new MockTranslateClient(&driver_, pref_service_.get())); 87 client_.reset(new MockTranslateClient(&driver_, pref_service_.get()));
88 88
89 manager_.reset(new TranslateManager(client_.get(), "hi")); 89 manager_.reset(new TranslateManager(client_.get(), "hi"));
90 manager_->GetLanguageState().set_translation_declined(false); 90 manager_->GetLanguageState().set_translation_declined(false);
91 91
92 delegate_.reset( 92 delegate_.reset(
93 new TranslateUIDelegate(manager_->GetWeakPtr(), "ar", "fr")); 93 new TranslateUIDelegate(manager_->GetWeakPtr(), "ar", "fr"));
94 94
95 ASSERT_FALSE(client_->GetTranslatePrefs()->IsTooOftenDenied("ar")); 95 ASSERT_FALSE(client_->GetTranslatePrefs()->IsTooOftenDenied("ar"));
96 } 96 }
97 97
98 MockTranslateDriver driver_; 98 MockTranslateDriver driver_;
99 std::unique_ptr<MockTranslateClient> client_; 99 std::unique_ptr<MockTranslateClient> client_;
100 std::unique_ptr<user_prefs::TestingPrefServiceSyncable> pref_service_; 100 std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> pref_service_;
101 std::unique_ptr<TranslateManager> manager_; 101 std::unique_ptr<TranslateManager> manager_;
102 std::unique_ptr<TranslateUIDelegate> delegate_; 102 std::unique_ptr<TranslateUIDelegate> delegate_;
103 103
104 private: 104 private:
105 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegateTest); 105 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegateTest);
106 }; 106 };
107 107
108 TEST_F(TranslateUIDelegateTest, CheckDeclinedFalse) { 108 TEST_F(TranslateUIDelegateTest, CheckDeclinedFalse) {
109 std::unique_ptr<TranslatePrefs> prefs(client_->GetTranslatePrefs()); 109 std::unique_ptr<TranslatePrefs> prefs(client_->GetTranslatePrefs());
110 for (int i = 0; i < 10; i++) { 110 for (int i = 0; i < 10; i++) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 prefs->IncrementTranslationAcceptedCount("ar"); 196 prefs->IncrementTranslationAcceptedCount("ar");
197 197
198 EXPECT_FALSE(delegate_->ShouldAlwaysTranslateBeCheckedByDefault()); 198 EXPECT_FALSE(delegate_->ShouldAlwaysTranslateBeCheckedByDefault());
199 } 199 }
200 200
201 // TODO(ftang) Currently this file only test TranslationDeclined(), we 201 // TODO(ftang) Currently this file only test TranslationDeclined(), we
202 // need to add the test for other functions soon to increase the test 202 // need to add the test for other functions soon to increase the test
203 // coverage. 203 // coverage.
204 204
205 } // namespace translate 205 } // namespace translate
OLDNEW
« no previous file with comments | « components/translate/core/browser/translate_ranker_unittest.cc ('k') | extensions/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698