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

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

Issue 2261793002: Bring the feedback button to the Mac sad tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Address second wave of comments, turn off feedback in non-Chrome builds Created 4 years, 3 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.h"
6
7 #import "base/mac/foundation_util.h"
8 #include "base/mac/scoped_nsobject.h"
9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #import "ui/base/cocoa/controls/hyperlink_text_view.h"
13
14 namespace {
15
16 template <typename T>
17 T* FindSadTabSubview(NSView* sadTabView) {
18 NSView* containerView = sadTabView.subviews.firstObject;
19 for (NSView* view in [containerView subviews]) {
20 if (auto subview = base::mac::ObjCCast<T>(view))
21 return subview;
22 }
23 return nil;
24 }
25
26 class SadTabViewTest : public CocoaTest {
27 public:
28 SadTabViewTest() {
29 base::scoped_nsobject<SadTabView> view([SadTabView new]);
30 view_ = view;
31 [[test_window() contentView] addSubview:view_];
32 }
33
34 SadTabView* view_; // Weak. Owned by the view hierarchy.
35 };
36
37 TEST_VIEW(SadTabViewTest, view_);
38
39 TEST(SadTabViewBehaviorTest, ClickOnLinks) {
40 using chrome::SadTab;
41 using Action = SadTab::Action;
42
43 class MockSadTab : public chrome::SadTab {
44 public:
45 MockSadTab() : SadTab(nullptr, chrome::SAD_TAB_KIND_CRASHED) {}
46 MOCK_METHOD0(RecordFirstPaint, void());
47 MOCK_METHOD1(PerformAction, void(Action));
48 };
49
50 MockSadTab sadTab;
51
52 base::scoped_nsobject<SadTabView> view(
53 [[SadTabView alloc] initWithFrame:NSZeroRect sadTab:&sadTab]);
54
55 EXPECT_CALL(sadTab, RecordFirstPaint());
56 EXPECT_CALL(sadTab, PerformAction(testing::TypedEq<Action>(Action::BUTTON)));
57 EXPECT_CALL(sadTab,
58 PerformAction(testing::TypedEq<Action>(Action::HELP_LINK)));
59
60 [view displayIfNeeded];
61 [FindSadTabSubview<NSButton>(view) performClick:nil];
62 [FindSadTabSubview<HyperlinkTextView>(view) clickedOnLink:[NSNull null]
63 atIndex:0];
64 }
65
66 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tab_contents/sad_tab_mac.mm ('k') | chrome/browser/ui/cocoa/tab_contents/sad_tab_view_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698