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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_notification_controller_unittest.mm

Issue 54303007: [rAc OSX] Add support for tooltips in notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_notification_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h" 5 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
8 #include "testing/gtest_mac.h" 10 #include "testing/gtest_mac.h"
9 #import "ui/base/test/ui_cocoa_test_helper.h" 11 #import "ui/base/test/ui_cocoa_test_helper.h"
10 12
11 namespace { 13 namespace {
12 14
13 class AutofillNotificationControllerTest : public ui::CocoaTest { 15 class AutofillNotificationControllerTest : public ui::CocoaTest {
14 public: 16 public:
15 virtual void SetUp() { 17 virtual void SetUp() {
16 CocoaTest::SetUp(); 18 CocoaTest::SetUp();
17 controller_.reset([[AutofillNotificationController alloc] init]); 19 InitControllerWithNotification(
18 [[test_window() contentView] addSubview:[controller_ view]]; 20 autofill::DialogNotification(autofill::DialogNotification::NONE,
21 ASCIIToUTF16("A notification title")));
22 }
23
24 void InitControllerWithNotification(
25 const autofill::DialogNotification& notification) {
26 controller_.reset(
27 [[AutofillNotificationController alloc]
28 initWithNotification:&notification]);
29 [[test_window() contentView] setSubviews:@[[controller_ view]]];
19 } 30 }
20 31
21 protected: 32 protected:
22 base::scoped_nsobject<AutofillNotificationController> controller_; 33 base::scoped_nsobject<AutofillNotificationController> controller_;
23 }; 34 };
24 35
25 } // namespace 36 } // namespace
26 37
27 TEST_VIEW(AutofillNotificationControllerTest, [controller_ view]) 38 TEST_VIEW(AutofillNotificationControllerTest, [controller_ view])
28 39
29 TEST_F(AutofillNotificationControllerTest, Subviews) { 40 TEST_F(AutofillNotificationControllerTest, Subviews) {
30 NSView* view = [controller_ view]; 41 NSView* view = [controller_ view];
31 ASSERT_EQ(2U, [[view subviews] count]); 42 ASSERT_EQ(3U, [[view subviews] count]);
32 EXPECT_TRUE([[[view subviews] objectAtIndex:0] isKindOfClass: 43 EXPECT_TRUE([[[view subviews] objectAtIndex:0] isKindOfClass:
33 [NSTextField class]]); 44 [NSTextField class]]);
34 EXPECT_TRUE([[[view subviews] objectAtIndex:1] isKindOfClass: 45 EXPECT_TRUE([[[view subviews] objectAtIndex:1] isKindOfClass:
35 [NSButton class]]); 46 [NSButton class]]);
47 EXPECT_TRUE([[[view subviews] objectAtIndex:2] isKindOfClass:
48 [NSImageView class]]);
36 EXPECT_NSEQ([controller_ textfield], 49 EXPECT_NSEQ([controller_ textfield],
37 [[view subviews] objectAtIndex:0]); 50 [[view subviews] objectAtIndex:0]);
38 EXPECT_NSEQ([controller_ checkbox], 51 EXPECT_NSEQ([controller_ checkbox],
39 [[view subviews] objectAtIndex:1]); 52 [[view subviews] objectAtIndex:1]);
53 EXPECT_NSEQ([controller_ tooltipIcon],
54 [[view subviews] objectAtIndex:2]);
40 55
41 // Just to exercise the code path. 56 // Just to exercise the code path.
42 [controller_ performLayout]; 57 [controller_ performLayout];
43 } 58 }
59
60 TEST_F(AutofillNotificationControllerTest, TextLabelOnly) {
61 InitControllerWithNotification(
62 autofill::DialogNotification(
63 autofill::DialogNotification::DEVELOPER_WARNING,
64 ASCIIToUTF16("A notification title")));
65
66 EXPECT_FALSE([[controller_ textfield] isHidden]);
67 EXPECT_TRUE([[controller_ checkbox] isHidden]);
68 EXPECT_TRUE([[controller_ tooltipIcon] isHidden]);
69 }
70
71 TEST_F(AutofillNotificationControllerTest, CheckboxOnly) {
72 autofill::DialogNotification notification(
73 autofill::DialogNotification::WALLET_USAGE_CONFIRMATION,
74 ASCIIToUTF16("A notification title"));
75 ASSERT_TRUE(notification.HasCheckbox());
76 InitControllerWithNotification(notification);
77
78 EXPECT_TRUE([[controller_ textfield] isHidden]);
79 EXPECT_FALSE([[controller_ checkbox] isHidden]);
80 EXPECT_TRUE([[controller_ tooltipIcon] isHidden]);
81 }
82
83 TEST_F(AutofillNotificationControllerTest, TextLabelAndTooltip) {
84 autofill::DialogNotification notification(
85 autofill::DialogNotification::DEVELOPER_WARNING,
86 ASCIIToUTF16("A notification title"));
87 notification.set_tooltip_text(ASCIIToUTF16("My very informative tooltip."));
88 InitControllerWithNotification(notification);
89
90 EXPECT_FALSE([[controller_ textfield] isHidden]);
91 EXPECT_TRUE([[controller_ checkbox] isHidden]);
92 EXPECT_FALSE([[controller_ tooltipIcon] isHidden]);
93 EXPECT_NSEQ(@"My very informative tooltip.",
94 [[controller_ tooltipIcon] toolTip]);
95 }
96
97 TEST_F(AutofillNotificationControllerTest, CheckboxAndTooltip) {
98 autofill::DialogNotification notification(
99 autofill::DialogNotification::WALLET_USAGE_CONFIRMATION,
100 ASCIIToUTF16("A notification title"));
101 ASSERT_TRUE(notification.HasCheckbox());
102 notification.set_tooltip_text(ASCIIToUTF16("My very informative tooltip."));
103 InitControllerWithNotification(notification);
104
105 EXPECT_TRUE([[controller_ textfield] isHidden]);
106 EXPECT_FALSE([[controller_ checkbox] isHidden]);
107 EXPECT_FALSE([[controller_ tooltipIcon] isHidden]);
108 EXPECT_NSEQ(@"My very informative tooltip.",
109 [[controller_ tooltipIcon] toolTip]);
110 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_notification_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698