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

Side by Side Diff: chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm

Issue 159883002: Move TranslatePrefs to the Translate component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@acceptLanguages
Patch Set: Fix ChromeOS browsertests Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "base/mac/scoped_nsobject.h" 7 #import "base/mac/scoped_nsobject.h"
8 #import "base/strings/string_util.h" 8 #import "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #import "chrome/app/chrome_command_ids.h" // For translate menu command ids. 10 #import "chrome/app/chrome_command_ids.h" // For translate menu command ids.
11 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
12 #import "chrome/browser/translate/translate_infobar_delegate.h" 12 #import "chrome/browser/translate/translate_infobar_delegate.h"
13 #import "chrome/browser/translate/translate_tab_helper.h"
13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 14 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
14 #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" 15 #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h"
15 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" 16 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h"
16 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h" 17 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h"
17 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
18 #include "components/translate/core/browser/translate_language_list.h" 19 #include "components/translate/core/browser/translate_language_list.h"
19 #import "content/public/browser/web_contents.h" 20 #import "content/public/browser/web_contents.h"
20 #include "ipc/ipc_message.h" 21 #include "ipc/ipc_message.h"
21 #import "testing/gmock/include/gmock/gmock.h" 22 #import "testing/gmock/include/gmock/gmock.h"
22 #import "testing/gtest/include/gtest/gtest.h" 23 #import "testing/gtest/include/gtest/gtest.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 EXPECT_CALL(*infobar_delegate(), Translate()) 228 EXPECT_CALL(*infobar_delegate(), Translate())
228 .Times(0); 229 .Times(0);
229 EXPECT_TRUE( 230 EXPECT_TRUE(
230 [infobar_controller_ verifyLayout]) << "Layout wrong, for state #" << i; 231 [infobar_controller_ verifyLayout]) << "Layout wrong, for state #" << i;
231 } 232 }
232 } 233 }
233 234
234 // Verify that the infobar shows the "Always translate this language" button 235 // Verify that the infobar shows the "Always translate this language" button
235 // after doing 3 translations. 236 // after doing 3 translations.
236 TEST_F(TranslationInfoBarTest, TriggerShowAlwaysTranslateButton) { 237 TEST_F(TranslationInfoBarTest, TriggerShowAlwaysTranslateButton) {
237 TranslatePrefs translate_prefs(profile()->GetPrefs()); 238 scoped_ptr<TranslatePrefs> translate_prefs(
238 translate_prefs.ResetTranslationAcceptedCount("en"); 239 TranslateTabHelper::CreateTranslatePrefs(profile()->GetPrefs()));
240 translate_prefs->ResetTranslationAcceptedCount("en");
239 for (int i = 0; i < 4; ++i) { 241 for (int i = 0; i < 4; ++i) {
240 translate_prefs.IncrementTranslationAcceptedCount("en"); 242 translate_prefs->IncrementTranslationAcceptedCount("en");
241 } 243 }
242 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); 244 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE);
243 BeforeTranslateInfobarController* controller = 245 BeforeTranslateInfobarController* controller =
244 (BeforeTranslateInfobarController*)infobar_controller_.get(); 246 (BeforeTranslateInfobarController*)infobar_controller_.get();
245 EXPECT_TRUE([[controller alwaysTranslateButton] superview] != nil); 247 EXPECT_TRUE([[controller alwaysTranslateButton] superview] != nil);
246 EXPECT_TRUE([[controller neverTranslateButton] superview] == nil); 248 EXPECT_TRUE([[controller neverTranslateButton] superview] == nil);
247 } 249 }
248 250
249 // Verify that the infobar shows the "Never translate this language" button 251 // Verify that the infobar shows the "Never translate this language" button
250 // after denying 3 translations. 252 // after denying 3 translations.
251 TEST_F(TranslationInfoBarTest, TriggerShowNeverTranslateButton) { 253 TEST_F(TranslationInfoBarTest, TriggerShowNeverTranslateButton) {
252 TranslatePrefs translate_prefs(profile()->GetPrefs()); 254 scoped_ptr<TranslatePrefs> translate_prefs(
253 translate_prefs.ResetTranslationDeniedCount("en"); 255 TranslateTabHelper::CreateTranslatePrefs(profile()->GetPrefs()));
256 translate_prefs->ResetTranslationDeniedCount("en");
254 for (int i = 0; i < 4; ++i) { 257 for (int i = 0; i < 4; ++i) {
255 translate_prefs.IncrementTranslationDeniedCount("en"); 258 translate_prefs->IncrementTranslationDeniedCount("en");
256 } 259 }
257 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); 260 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE);
258 BeforeTranslateInfobarController* controller = 261 BeforeTranslateInfobarController* controller =
259 (BeforeTranslateInfobarController*)infobar_controller_.get(); 262 (BeforeTranslateInfobarController*)infobar_controller_.get();
260 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); 263 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil);
261 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); 264 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil);
262 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698