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

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

Issue 10534093: TabContentsWrapper -> TabContents, part 37. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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/memory/scoped_nsobject.h" 7 #import "base/memory/scoped_nsobject.h"
8 #import "base/string_util.h" 8 #import "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/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 #import "chrome/browser/translate/translate_infobar_delegate.h" 11 #import "chrome/browser/translate/translate_infobar_delegate.h"
12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
13 #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" 13 #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h"
14 #import "chrome/browser/ui/cocoa/infobars/infobar.h" 14 #import "chrome/browser/ui/cocoa/infobars/infobar.h"
15 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h" 15 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
17 #import "content/public/browser/web_contents.h" 17 #import "content/public/browser/web_contents.h"
18 #import "testing/gmock/include/gmock/gmock.h" 18 #import "testing/gmock/include/gmock/gmock.h"
19 #import "testing/gtest/include/gtest/gtest.h" 19 #import "testing/gtest/include/gtest/gtest.h"
20 #import "testing/platform_test.h" 20 #import "testing/platform_test.h"
21 21
22 using content::WebContents; 22 using content::WebContents;
23 23
24 namespace { 24 namespace {
25 25
26 // All states the translate toolbar can assume. 26 // All states the translate toolbar can assume.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 MOCK_METHOD0(ToggleSiteBlacklist, void()); 67 MOCK_METHOD0(ToggleSiteBlacklist, void());
68 MOCK_METHOD0(ToggleAlwaysTranslate, void()); 68 MOCK_METHOD0(ToggleAlwaysTranslate, void());
69 }; 69 };
70 70
71 class TranslationInfoBarTest : public CocoaProfileTest { 71 class TranslationInfoBarTest : public CocoaProfileTest {
72 public: 72 public:
73 // Each test gets a single Mock translate delegate for the lifetime of 73 // Each test gets a single Mock translate delegate for the lifetime of
74 // the test. 74 // the test.
75 virtual void SetUp() { 75 virtual void SetUp() {
76 CocoaProfileTest::SetUp(); 76 CocoaProfileTest::SetUp();
77 tab_contents_.reset(new TabContentsWrapper(WebContents::Create( 77 tab_contents_.reset(new TabContents(WebContents::Create(
78 profile(), NULL, MSG_ROUTING_NONE, NULL, NULL))); 78 profile(), NULL, MSG_ROUTING_NONE, NULL, NULL)));
79 CreateInfoBar(); 79 CreateInfoBar();
80 } 80 }
81 81
82 void CreateInfoBar() { 82 void CreateInfoBar() {
83 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); 83 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE);
84 } 84 }
85 85
86 void CreateInfoBar(TranslateInfoBarDelegate::Type type) { 86 void CreateInfoBar(TranslateInfoBarDelegate::Type type) {
87 TranslateErrors::Type error = TranslateErrors::NONE; 87 TranslateErrors::Type error = TranslateErrors::NONE;
(...skipping 11 matching lines...) Expand all
99 infobar_controller_.reset( 99 infobar_controller_.reset(
100 reinterpret_cast<TranslateInfoBarControllerBase*>( 100 reinterpret_cast<TranslateInfoBarControllerBase*>(
101 infobar->controller())); 101 infobar->controller()));
102 // We need to set the window to be wide so that the options button 102 // We need to set the window to be wide so that the options button
103 // doesn't overlap the other buttons. 103 // doesn't overlap the other buttons.
104 [test_window() setContentSize:NSMakeSize(2000, 500)]; 104 [test_window() setContentSize:NSMakeSize(2000, 500)];
105 [[infobar_controller_ view] setFrame:NSMakeRect(0, 0, 2000, 500)]; 105 [[infobar_controller_ view] setFrame:NSMakeRect(0, 0, 2000, 500)];
106 [[test_window() contentView] addSubview:[infobar_controller_ view]]; 106 [[test_window() contentView] addSubview:[infobar_controller_ view]];
107 } 107 }
108 108
109 scoped_ptr<TabContentsWrapper> tab_contents_; 109 scoped_ptr<TabContents> tab_contents_;
110 scoped_ptr<MockTranslateInfoBarDelegate> infobar_delegate_; 110 scoped_ptr<MockTranslateInfoBarDelegate> infobar_delegate_;
111 scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller_; 111 scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller_;
112 }; 112 };
113 113
114 // Check that we can instantiate a Translate Infobar correctly. 114 // Check that we can instantiate a Translate Infobar correctly.
115 TEST_F(TranslationInfoBarTest, Instantiate) { 115 TEST_F(TranslationInfoBarTest, Instantiate) {
116 CreateInfoBar(); 116 CreateInfoBar();
117 ASSERT_TRUE(infobar_controller_.get()); 117 ASSERT_TRUE(infobar_controller_.get());
118 } 118 }
119 119
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 translate_prefs.IncrementTranslationDeniedCount("en"); 247 translate_prefs.IncrementTranslationDeniedCount("en");
248 } 248 }
249 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); 249 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE);
250 BeforeTranslateInfobarController* controller = 250 BeforeTranslateInfobarController* controller =
251 (BeforeTranslateInfobarController*)infobar_controller_.get(); 251 (BeforeTranslateInfobarController*)infobar_controller_.get();
252 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); 252 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil);
253 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); 253 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil);
254 } 254 }
255 255
256 } // namespace 256 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm ('k') | chrome/browser/ui/cocoa/keystone_infobar_delegate.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698