1 // Copyright 2014 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.
5 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_confirmation_view_controller.h"
7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h"
10 #import "chrome/browser/ui/cocoa/bubble_combobox.h"
11 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
12 #include "chrome/browser/ui/cocoa/passwords/manage_passwords_controller_test.h"
13 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
14 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
15 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/gtest_mac.h"
19 @interface ManagePasswordsBubbleContentViewTestDelegate
20 : NSObject<ManagePasswordsBubbleContentViewDelegate> {
23 @property(readonly) BOOL dismissed;
26 @implementation ManagePasswordsBubbleContentViewTestDelegate
28 @synthesize dismissed = dismissed_;
30 - (void)viewShouldDismiss {
38 class ManagePasswordsBubbleConfirmationViewControllerTest
39 : public ManagePasswordsControllerTest {
41 ManagePasswordsBubbleConfirmationViewControllerTest() : controller_(nil) {}
43 virtual void SetUp() OVERRIDE {
44 ManagePasswordsControllerTest::SetUp();
46 [[ManagePasswordsBubbleContentViewTestDelegate alloc] init]);
49 ManagePasswordsBubbleContentViewTestDelegate* delegate() {
50 return delegate_.get();
53 ManagePasswordsBubbleConfirmationViewController* controller() {
55 controller_.reset([[ManagePasswordsBubbleConfirmationViewController alloc]
57 delegate:delegate()]);
58 [controller_ loadView];
60 return controller_.get();
64 base::scoped_nsobject<ManagePasswordsBubbleConfirmationViewController>
66 base::scoped_nsobject<ManagePasswordsBubbleContentViewTestDelegate> delegate_;
69 TEST_F(ManagePasswordsBubbleConfirmationViewControllerTest,
70 ShouldDismissWhenOKClicked) {
71 [controller().okButton performClick:nil];
72 EXPECT_TRUE([delegate() dismissed]);
75 TEST_F(ManagePasswordsBubbleConfirmationViewControllerTest,
76 ShouldOpenPasswordsAndDismissWhenLinkClicked) {
77 [controller().confirmationText clickedOnLink:nil atIndex:0];
78 EXPECT_TRUE([delegate() dismissed]);
79 EXPECT_TRUE(ui_controller()->navigated_to_settings_page());