OLD | NEW |
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/memory/scoped_nsobject.h" | 7 #import "base/memory/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 #include "chrome/browser/translate/translate_language_list.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.h" | 16 #import "chrome/browser/ui/cocoa/infobars/infobar.h" |
16 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h" | 17 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h" |
17 #import "content/public/browser/web_contents.h" | 18 #import "content/public/browser/web_contents.h" |
18 #include "ipc/ipc_message.h" | 19 #include "ipc/ipc_message.h" |
19 #import "testing/gmock/include/gmock/gmock.h" | 20 #import "testing/gmock/include/gmock/gmock.h" |
20 #import "testing/gtest/include/gtest/gtest.h" | 21 #import "testing/gtest/include/gtest/gtest.h" |
21 #import "testing/platform_test.h" | 22 #import "testing/platform_test.h" |
22 | 23 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 MOCK_METHOD0(ToggleSiteBlacklist, void()); | 55 MOCK_METHOD0(ToggleSiteBlacklist, void()); |
55 virtual bool ShouldAlwaysTranslate() OVERRIDE { return false; } | 56 virtual bool ShouldAlwaysTranslate() OVERRIDE { return false; } |
56 MOCK_METHOD0(ToggleAlwaysTranslate, void()); | 57 MOCK_METHOD0(ToggleAlwaysTranslate, void()); |
57 }; | 58 }; |
58 | 59 |
59 class TranslationInfoBarTest : public CocoaProfileTest { | 60 class TranslationInfoBarTest : public CocoaProfileTest { |
60 public: | 61 public: |
61 // Each test gets a single Mock translate delegate for the lifetime of | 62 // Each test gets a single Mock translate delegate for the lifetime of |
62 // the test. | 63 // the test. |
63 virtual void SetUp() { | 64 virtual void SetUp() { |
| 65 TranslateLanguageList::DisableUpdate(); |
64 CocoaProfileTest::SetUp(); | 66 CocoaProfileTest::SetUp(); |
65 web_contents_.reset( | 67 web_contents_.reset( |
66 WebContents::Create(WebContents::CreateParams(profile()))); | 68 WebContents::Create(WebContents::CreateParams(profile()))); |
67 InfoBarService::CreateForWebContents(web_contents_.get()); | 69 InfoBarService::CreateForWebContents(web_contents_.get()); |
68 CreateInfoBar(); | 70 CreateInfoBar(); |
69 } | 71 } |
70 | 72 |
71 void CreateInfoBar() { | 73 void CreateInfoBar() { |
72 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); | 74 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); |
73 } | 75 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 translate_prefs.IncrementTranslationDeniedCount("en"); | 246 translate_prefs.IncrementTranslationDeniedCount("en"); |
245 } | 247 } |
246 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); | 248 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); |
247 BeforeTranslateInfobarController* controller = | 249 BeforeTranslateInfobarController* controller = |
248 (BeforeTranslateInfobarController*)infobar_controller_.get(); | 250 (BeforeTranslateInfobarController*)infobar_controller_.get(); |
249 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); | 251 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); |
250 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); | 252 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); |
251 } | 253 } |
252 | 254 |
253 } // namespace | 255 } // namespace |
OLD | NEW |