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

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/sad_tab_controller_unittest.mm

Issue 7610011: Update Sad Tab help text and link. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor cleanup in SadTabController. Created 9 years, 4 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 #include "base/debug/debugger.h" 5 #include "base/debug/debugger.h"
6 #include "base/memory/scoped_nsobject.h" 6 #include "base/memory/scoped_nsobject.h"
7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
8 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" 8 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h"
9 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view.h" 9 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
11 #include "content/browser/renderer_host/test_render_view_host.h" 11 #include "content/browser/renderer_host/test_render_view_host.h"
12 #include "content/browser/tab_contents/test_tab_contents.h" 12 #include "content/browser/tab_contents/test_tab_contents.h"
13 13
14 @interface SadTabView (ExposedForTesting) 14 @interface SadTabView (ExposedForTesting)
15 // Implementation is below. 15 // Implementation is below.
16 - (NSButton*)linkButton; 16 - (NSTextView*)helpTextView;
17 @end 17 @end
18 18
19 @implementation SadTabView (ExposedForTesting) 19 @implementation SadTabView (ExposedForTesting)
20 - (NSButton*)linkButton { 20 - (NSTextView*)helpTextView {
21 return linkButton_; 21 return help_.get();
22 } 22 }
23 @end 23 @end
24 24
25 namespace { 25 namespace {
26 26
27 class SadTabControllerTest : public RenderViewHostTestHarness { 27 class SadTabControllerTest : public RenderViewHostTestHarness {
28 public: 28 public:
29 SadTabControllerTest() : test_window_(nil) { 29 SadTabControllerTest() : test_window_(nil) {
30 link_clicked_ = false; 30 link_clicked_ = false;
31 } 31 }
(...skipping 23 matching lines...) Expand all
55 SadTabController* controller = 55 SadTabController* controller =
56 [[SadTabController alloc] initWithTabContents:contents() 56 [[SadTabController alloc] initWithTabContents:contents()
57 superview:contentView]; 57 superview:contentView];
58 EXPECT_TRUE(controller); 58 EXPECT_TRUE(controller);
59 NSView* view = [controller view]; 59 NSView* view = [controller view];
60 EXPECT_TRUE(view); 60 EXPECT_TRUE(view);
61 61
62 return controller; 62 return controller;
63 } 63 }
64 64
65 NSButton* GetLinkButton(SadTabController* controller) { 65 NSTextView* GetHelpTextView(SadTabController* controller) {
66 SadTabView* view = static_cast<SadTabView*>([controller view]); 66 SadTabView* view = static_cast<SadTabView*>([controller view]);
67 return ([view linkButton]); 67 return ([view helpTextView]);
68 } 68 }
69 69
70 static bool link_clicked_; 70 static bool link_clicked_;
71 CocoaTestHelperWindow* test_window_; 71 CocoaTestHelperWindow* test_window_;
72 }; 72 };
73 73
74 // static 74 // static
75 bool SadTabControllerTest::link_clicked_; 75 bool SadTabControllerTest::link_clicked_;
76 76
77 TEST_F(SadTabControllerTest, WithTabContents) { 77 TEST_F(SadTabControllerTest, WithTabContents) {
78 scoped_nsobject<SadTabController> controller(CreateController()); 78 scoped_nsobject<SadTabController> controller(CreateController());
79 EXPECT_TRUE(controller); 79 EXPECT_TRUE(controller);
80 NSButton* link = GetLinkButton(controller); 80 NSTextView* help = GetHelpTextView(controller);
81 EXPECT_TRUE(link); 81 EXPECT_TRUE(help);
82 } 82 }
83 83
84 TEST_F(SadTabControllerTest, WithoutTabContents) { 84 TEST_F(SadTabControllerTest, WithoutTabContents) {
85 DeleteContents(); 85 DeleteContents();
86 scoped_nsobject<SadTabController> controller(CreateController()); 86 scoped_nsobject<SadTabController> controller(CreateController());
87 EXPECT_TRUE(controller); 87 EXPECT_TRUE(controller);
88 NSButton* link = GetLinkButton(controller); 88 NSTextView* help = GetHelpTextView(controller);
89 EXPECT_FALSE(link); 89 EXPECT_FALSE(help);
90 } 90 }
91 91
92 TEST_F(SadTabControllerTest, ClickOnLink) { 92 TEST_F(SadTabControllerTest, ClickOnLink) {
93 scoped_nsobject<SadTabController> controller(CreateController()); 93 scoped_nsobject<SadTabController> controller(CreateController());
94 NSButton* link = GetLinkButton(controller); 94 NSTextView* help = GetHelpTextView(controller);
95 EXPECT_TRUE(link); 95 EXPECT_TRUE(help);
96 EXPECT_FALSE(link_clicked_); 96 EXPECT_FALSE(link_clicked_);
97 [link performClick:link]; 97 [help clickedOnLink:nil atIndex:0];
98 EXPECT_TRUE(link_clicked_); 98 EXPECT_TRUE(link_clicked_);
99 } 99 }
100 100
101 } // namespace 101 } // namespace
102 102
103 @implementation NSApplication (SadTabControllerUnitTest) 103 @implementation NSApplication (SadTabControllerUnitTest)
104 // Add handler for the openLearnMoreAboutCrashLink: action to NSApp for testing 104 // Add handler for the openLearnMoreAboutCrashLink: action to NSApp for testing
105 // purposes. Normally this would be sent up the responder tree correctly, but 105 // purposes. Normally this would be sent up the responder tree correctly, but
106 // since tests run in the background, key window and main window are never set 106 // since tests run in the background, key window and main window are never set
107 // on NSApplication. Adding it to NSApplication directly removes the need for 107 // on NSApplication. Adding it to NSApplication directly removes the need for
108 // worrying about what the current window with focus is. 108 // worrying about what the current window with focus is.
109 - (void)openLearnMoreAboutCrashLink:(id)sender { 109 - (void)openLearnMoreAboutCrashLink:(id)sender {
110 SadTabControllerTest::link_clicked_ = true; 110 SadTabControllerTest::link_clicked_ = true;
111 } 111 }
112 112
113 @end 113 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698