OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_main_container.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "chrome/browser/ui/autofill/mock_autofill_dialog_controller.h" | 8 #include "chrome/browser/ui/autofill/mock_autofill_dialog_controller.h" |
9 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" | 9 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 }; | 28 }; |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 TEST_VIEW(AutofillMainContainerTest, [container_ view]) | 32 TEST_VIEW(AutofillMainContainerTest, [container_ view]) |
33 | 33 |
34 TEST_F(AutofillMainContainerTest, SubViews) { | 34 TEST_F(AutofillMainContainerTest, SubViews) { |
35 bool hasButtons = false; | 35 bool hasButtons = false; |
36 bool hasTextView = false; | 36 bool hasTextView = false; |
37 bool hasDetailsContainer = false; | 37 bool hasDetailsContainer = false; |
38 bool hasCheckbox = false; | |
38 int hasNotificationContainer = false; | 39 int hasNotificationContainer = false; |
39 | 40 |
40 // Should have account chooser, button strip, and details section. | 41 // Should have account chooser, button strip, and details section. |
41 EXPECT_EQ(4U, [[[container_ view] subviews] count]); | 42 EXPECT_EQ(5U, [[[container_ view] subviews] count]); |
42 for (NSView* view in [[container_ view] subviews]) { | 43 for (NSView* view in [[container_ view] subviews]) { |
43 NSArray* subviews = [view subviews]; | 44 NSArray* subviews = [view subviews]; |
44 if ([subviews count] == 2) { | 45 if ([subviews count] == 2) { |
45 EXPECT_TRUE( | 46 EXPECT_TRUE( |
46 [[subviews objectAtIndex:0] isKindOfClass:[NSButton class]]); | 47 [[subviews objectAtIndex:0] isKindOfClass:[NSButton class]]); |
47 EXPECT_TRUE( | 48 EXPECT_TRUE( |
48 [[subviews objectAtIndex:1] isKindOfClass:[NSButton class]]); | 49 [[subviews objectAtIndex:1] isKindOfClass:[NSButton class]]); |
49 hasButtons = true; | 50 hasButtons = true; |
50 } else if ([view isKindOfClass:[NSTextView class]]) { | 51 } else if ([view isKindOfClass:[NSTextView class]]) { |
51 hasTextView = true; | 52 hasTextView = true; |
52 } else if ([subviews count] > 0 && | 53 } else if ([subviews count] > 0 && |
53 [[subviews objectAtIndex:0] isKindOfClass: | 54 [[subviews objectAtIndex:0] isKindOfClass: |
54 [AutofillSectionView class]]) { | 55 [AutofillSectionView class]]) { |
55 hasDetailsContainer = true; | 56 hasDetailsContainer = true; |
57 } else if ([view isKindOfClass:[NSButton class]] && | |
58 view == [container_ saveInChromeCheckboxForTesting]) { | |
Robert Sesek
2013/07/16 18:40:38
nit: align with [
groby-ooo-7-16
2013/07/16 19:55:39
I blame my editor! ;) (Done, and so is the branch
| |
59 hasCheckbox = true; | |
56 } else { | 60 } else { |
57 // Assume by default this is the notification area view. | 61 // Assume by default this is the notification area view. |
58 // There is no way to easily verify that with more detail. | 62 // There is no way to easily verify that with more detail. |
59 hasNotificationContainer = true; | 63 hasNotificationContainer = true; |
60 } | 64 } |
61 } | 65 } |
62 | 66 |
63 EXPECT_TRUE(hasButtons); | 67 EXPECT_TRUE(hasButtons); |
64 EXPECT_TRUE(hasTextView); | 68 EXPECT_TRUE(hasTextView); |
65 EXPECT_TRUE(hasDetailsContainer); | 69 EXPECT_TRUE(hasDetailsContainer); |
66 EXPECT_TRUE(hasNotificationContainer); | 70 EXPECT_TRUE(hasNotificationContainer); |
71 EXPECT_TRUE(hasCheckbox); | |
67 } | 72 } |
73 | |
74 TEST_F(AutofillMainContainerTest, SaveDetailsLocallyDefaultsToTrue) { | |
75 EXPECT_TRUE([container_ saveDetailsLocally]); | |
76 } | |
77 | |
78 TEST_F(AutofillMainContainerTest, SaveInChromeCheckboxVisibility) { | |
79 using namespace testing; | |
80 | |
81 // Tests that the checkbox is only visible if the controller allows it. | |
82 EXPECT_CALL(controller_, ShouldOfferToSaveInChrome()).Times(2) | |
83 .WillOnce(Return(false)) | |
84 .WillOnce(Return(true)); | |
85 | |
86 NSButton* checkbox = [container_ saveInChromeCheckboxForTesting]; | |
87 ASSERT_TRUE(checkbox); | |
88 | |
89 EXPECT_FALSE([checkbox isHidden]); | |
90 [container_ modelChanged]; | |
91 EXPECT_TRUE([checkbox isHidden]); | |
92 [container_ modelChanged]; | |
93 EXPECT_FALSE([checkbox isHidden]); | |
94 } | |
OLD | NEW |