OLD | NEW |
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" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
10 #include "testing/gtest_mac.h" | 10 #include "testing/gtest_mac.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 TEST_VIEW(AutofillNotificationControllerTest, [controller_ view]) | 39 TEST_VIEW(AutofillNotificationControllerTest, [controller_ view]) |
40 | 40 |
41 TEST_F(AutofillNotificationControllerTest, Subviews) { | 41 TEST_F(AutofillNotificationControllerTest, Subviews) { |
42 NSView* view = [controller_ view]; | 42 NSView* view = [controller_ view]; |
43 ASSERT_EQ(3U, [[view subviews] count]); | 43 ASSERT_EQ(3U, [[view subviews] count]); |
44 EXPECT_TRUE([[[view subviews] objectAtIndex:0] isKindOfClass: | 44 EXPECT_TRUE([[[view subviews] objectAtIndex:0] isKindOfClass: |
45 [NSTextView class]]); | 45 [NSTextView class]]); |
46 EXPECT_TRUE([[[view subviews] objectAtIndex:1] isKindOfClass: | 46 EXPECT_TRUE([[[view subviews] objectAtIndex:1] isKindOfClass: |
47 [NSButton class]]); | 47 [NSButton class]]); |
48 EXPECT_TRUE([[[view subviews] objectAtIndex:2] isKindOfClass: | 48 EXPECT_TRUE([[[view subviews] objectAtIndex:2] isKindOfClass: |
49 [NSImageView class]]); | 49 [NSButton class]]); |
50 EXPECT_NSEQ([controller_ textview], | 50 EXPECT_NSEQ([controller_ textview], |
51 [[view subviews] objectAtIndex:0]); | 51 [[view subviews] objectAtIndex:0]); |
52 EXPECT_NSEQ([controller_ checkbox], | 52 EXPECT_NSEQ([controller_ checkbox], |
53 [[view subviews] objectAtIndex:1]); | 53 [[view subviews] objectAtIndex:1]); |
54 EXPECT_NSEQ([controller_ tooltipIcon], | 54 EXPECT_NSEQ([controller_ tooltipView], |
55 [[view subviews] objectAtIndex:2]); | 55 [[view subviews] objectAtIndex:2]); |
56 | 56 |
57 // Just to exercise the code path. | 57 // Just to exercise the code path. |
58 [controller_ performLayout]; | 58 [controller_ performLayout]; |
59 } | 59 } |
60 | 60 |
61 TEST_F(AutofillNotificationControllerTest, TextLabelOnly) { | 61 TEST_F(AutofillNotificationControllerTest, TextLabelOnly) { |
62 InitControllerWithNotification( | 62 InitControllerWithNotification( |
63 autofill::DialogNotification( | 63 autofill::DialogNotification( |
64 autofill::DialogNotification::DEVELOPER_WARNING, | 64 autofill::DialogNotification::DEVELOPER_WARNING, |
65 ASCIIToUTF16("A notification title"))); | 65 ASCIIToUTF16("A notification title"))); |
66 | 66 |
67 EXPECT_FALSE([[controller_ textview] isHidden]); | 67 EXPECT_FALSE([[controller_ textview] isHidden]); |
68 EXPECT_TRUE([[controller_ checkbox] isHidden]); | 68 EXPECT_TRUE([[controller_ checkbox] isHidden]); |
69 EXPECT_TRUE([[controller_ tooltipIcon] isHidden]); | 69 EXPECT_TRUE([[controller_ tooltipView] isHidden]); |
70 } | 70 } |
71 | 71 |
72 TEST_F(AutofillNotificationControllerTest, CheckboxOnly) { | 72 TEST_F(AutofillNotificationControllerTest, CheckboxOnly) { |
73 autofill::DialogNotification notification( | 73 autofill::DialogNotification notification( |
74 autofill::DialogNotification::WALLET_USAGE_CONFIRMATION, | 74 autofill::DialogNotification::WALLET_USAGE_CONFIRMATION, |
75 ASCIIToUTF16("A notification title")); | 75 ASCIIToUTF16("A notification title")); |
76 ASSERT_TRUE(notification.HasCheckbox()); | 76 ASSERT_TRUE(notification.HasCheckbox()); |
77 InitControllerWithNotification(notification); | 77 InitControllerWithNotification(notification); |
78 | 78 |
79 EXPECT_TRUE([[controller_ textview] isHidden]); | 79 EXPECT_TRUE([[controller_ textview] isHidden]); |
80 EXPECT_FALSE([[controller_ checkbox] isHidden]); | 80 EXPECT_FALSE([[controller_ checkbox] isHidden]); |
81 EXPECT_TRUE([[controller_ tooltipIcon] isHidden]); | 81 EXPECT_TRUE([[controller_ tooltipView] isHidden]); |
82 } | 82 } |
83 | 83 |
84 TEST_F(AutofillNotificationControllerTest, TextLabelAndTooltip) { | 84 TEST_F(AutofillNotificationControllerTest, TextLabelAndTooltip) { |
85 autofill::DialogNotification notification( | 85 autofill::DialogNotification notification( |
86 autofill::DialogNotification::DEVELOPER_WARNING, | 86 autofill::DialogNotification::DEVELOPER_WARNING, |
87 ASCIIToUTF16("A notification title")); | 87 ASCIIToUTF16("A notification title")); |
88 notification.set_tooltip_text(ASCIIToUTF16("My very informative tooltip.")); | 88 notification.set_tooltip_text(ASCIIToUTF16("My very informative tooltip.")); |
89 InitControllerWithNotification(notification); | 89 InitControllerWithNotification(notification); |
90 | 90 |
91 EXPECT_FALSE([[controller_ textview] isHidden]); | 91 EXPECT_FALSE([[controller_ textview] isHidden]); |
92 EXPECT_TRUE([[controller_ checkbox] isHidden]); | 92 EXPECT_TRUE([[controller_ checkbox] isHidden]); |
93 EXPECT_FALSE([[controller_ tooltipIcon] isHidden]); | 93 EXPECT_FALSE([[controller_ tooltipView] isHidden]); |
94 EXPECT_NSEQ(@"My very informative tooltip.", | |
95 [[controller_ tooltipIcon] toolTip]); | |
96 } | 94 } |
97 | 95 |
98 TEST_F(AutofillNotificationControllerTest, CheckboxAndTooltip) { | 96 TEST_F(AutofillNotificationControllerTest, CheckboxAndTooltip) { |
99 autofill::DialogNotification notification( | 97 autofill::DialogNotification notification( |
100 autofill::DialogNotification::WALLET_USAGE_CONFIRMATION, | 98 autofill::DialogNotification::WALLET_USAGE_CONFIRMATION, |
101 ASCIIToUTF16("A notification title")); | 99 ASCIIToUTF16("A notification title")); |
102 ASSERT_TRUE(notification.HasCheckbox()); | 100 ASSERT_TRUE(notification.HasCheckbox()); |
103 notification.set_tooltip_text(ASCIIToUTF16("My very informative tooltip.")); | 101 notification.set_tooltip_text(ASCIIToUTF16("My very informative tooltip.")); |
104 InitControllerWithNotification(notification); | 102 InitControllerWithNotification(notification); |
105 | 103 |
106 EXPECT_TRUE([[controller_ textview] isHidden]); | 104 EXPECT_TRUE([[controller_ textview] isHidden]); |
107 EXPECT_FALSE([[controller_ checkbox] isHidden]); | 105 EXPECT_FALSE([[controller_ checkbox] isHidden]); |
108 EXPECT_FALSE([[controller_ tooltipIcon] isHidden]); | 106 EXPECT_FALSE([[controller_ tooltipView] isHidden]); |
109 EXPECT_NSEQ(@"My very informative tooltip.", | |
110 [[controller_ tooltipIcon] toolTip]); | |
111 } | 107 } |
OLD | NEW |