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

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

Issue 2130623002: rollback omnibar icon changes based on UX feedback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix patch/merge issue Created 4 years, 5 months 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_ui_delegate.cc ('k') | no next file » | 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"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Reset it to true again after delegate_->SetLanguageBlocked(true) 166 // Reset it to true again after delegate_->SetLanguageBlocked(true)
167 // turn it to false. 167 // turn it to false.
168 manager_->GetLanguageState().SetTranslateEnabled(true); 168 manager_->GetLanguageState().SetTranslateEnabled(true);
169 169
170 delegate_->SetLanguageBlocked(false); 170 delegate_->SetLanguageBlocked(false);
171 171
172 EXPECT_FALSE(prefs->IsBlockedLanguage("ar")); 172 EXPECT_FALSE(prefs->IsBlockedLanguage("ar"));
173 EXPECT_TRUE(manager_->GetLanguageState().translate_enabled()); 173 EXPECT_TRUE(manager_->GetLanguageState().translate_enabled());
174 } 174 }
175 175
176 TEST_F(TranslateUIDelegateTest, SetLanguageBlockedIn2016Q2UI) {
177 TurnOnTranslate2016Q2UIFlag();
178 std::unique_ptr<TranslatePrefs> prefs(client_->GetTranslatePrefs());
179 manager_->GetLanguageState().SetTranslateEnabled(true);
180 EXPECT_TRUE(manager_->GetLanguageState().translate_enabled());
181 prefs->UnblockLanguage("ar");
182 EXPECT_FALSE(prefs->IsBlockedLanguage("ar"));
183
184 delegate_->SetLanguageBlocked(true);
185
186 EXPECT_TRUE(prefs->IsBlockedLanguage("ar"));
187 EXPECT_TRUE(manager_->GetLanguageState().translate_enabled());
188
189 // Reset it to true again after delegate_->SetLanguageBlocked(true)
190 // turn it to false.
191 manager_->GetLanguageState().SetTranslateEnabled(true);
192
193 delegate_->SetLanguageBlocked(false);
194
195 EXPECT_FALSE(prefs->IsBlockedLanguage("ar"));
196 EXPECT_TRUE(manager_->GetLanguageState().translate_enabled());
197 }
198
199 TEST_F(TranslateUIDelegateTest, ShouldAlwaysTranslateBeCheckedByDefaultNever) { 176 TEST_F(TranslateUIDelegateTest, ShouldAlwaysTranslateBeCheckedByDefaultNever) {
200 std::unique_ptr<TranslatePrefs> prefs(client_->GetTranslatePrefs()); 177 std::unique_ptr<TranslatePrefs> prefs(client_->GetTranslatePrefs());
201 prefs->ResetTranslationAcceptedCount("ar"); 178 prefs->ResetTranslationAcceptedCount("ar");
202 179
203 for (int i = 0; i < 100; i++) { 180 for (int i = 0; i < 100; i++) {
204 EXPECT_FALSE(delegate_->ShouldAlwaysTranslateBeCheckedByDefault()); 181 EXPECT_FALSE(delegate_->ShouldAlwaysTranslateBeCheckedByDefault());
205 prefs->IncrementTranslationAcceptedCount("ar"); 182 prefs->IncrementTranslationAcceptedCount("ar");
206 } 183 }
207 } 184 }
208 185
(...skipping 20 matching lines...) Expand all
229 prefs->IncrementTranslationAcceptedCount("ar"); 206 prefs->IncrementTranslationAcceptedCount("ar");
230 207
231 EXPECT_FALSE(delegate_->ShouldAlwaysTranslateBeCheckedByDefault()); 208 EXPECT_FALSE(delegate_->ShouldAlwaysTranslateBeCheckedByDefault());
232 } 209 }
233 210
234 // TODO(ftang) Currently this file only test TranslationDeclined(), we 211 // TODO(ftang) Currently this file only test TranslationDeclined(), we
235 // need to add the test for other functions soon to increase the test 212 // need to add the test for other functions soon to increase the test
236 // coverage. 213 // coverage.
237 214
238 } // namespace translate 215 } // namespace translate
OLDNEW
« no previous file with comments | « components/translate/core/browser/translate_ui_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698