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

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

Issue 19287006: [rAC, OSX] "Save In Chrome" checkbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 7 years, 5 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
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_main_container.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 (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
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]) {
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_main_container.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698