| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" | 5 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 13 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 14 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 14 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 15 #include "chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.h" | 15 #include "chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.h" |
| 16 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_view_controller.h" | 16 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_view_controller.h" |
| 17 #import "chrome/browser/ui/cocoa/passwords/save_pending_password_view_controller
.h" | 17 #import "chrome/browser/ui/cocoa/passwords/save_pending_password_view_controller
.h" |
| 18 #import "chrome/browser/ui/cocoa/passwords/update_pending_password_view_controll
er.h" |
| 18 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 19 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| 19 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" | 20 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "testing/gtest_mac.h" | 22 #include "testing/gtest_mac.h" |
| 22 #include "testing/platform_test.h" | 23 #include "testing/platform_test.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 class ManagePasswordsBubbleControllerTest | 27 class ManagePasswordsBubbleControllerTest |
| 27 : public ManagePasswordsControllerTest { | 28 : public ManagePasswordsControllerTest { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 41 | 42 |
| 42 ManagePasswordsBubbleModel::DisplayReason GetDisplayReason() const override { | 43 ManagePasswordsBubbleModel::DisplayReason GetDisplayReason() const override { |
| 43 return ManagePasswordsBubbleModel::USER_ACTION; | 44 return ManagePasswordsBubbleModel::USER_ACTION; |
| 44 } | 45 } |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 ManagePasswordsBubbleController* controller_; // weak; owns itself. | 48 ManagePasswordsBubbleController* controller_; // weak; owns itself. |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 TEST_F(ManagePasswordsBubbleControllerTest, PendingStateShouldHavePendingView) { | 51 TEST_F(ManagePasswordsBubbleControllerTest, PendingStateShouldHavePendingView) { |
| 51 SetUpPendingState(); | 52 SetUpPendingState(false); |
| 52 EXPECT_EQ([SavePendingPasswordViewController class], | 53 EXPECT_EQ([SavePendingPasswordViewController class], |
| 53 [[controller() currentController] class]); | 54 [[controller() currentController] class]); |
| 54 } | 55 } |
| 55 | 56 |
| 56 TEST_F(ManagePasswordsBubbleControllerTest, DismissingShouldCloseWindow) { | 57 TEST_F(ManagePasswordsBubbleControllerTest, DismissingShouldCloseWindow) { |
| 57 SetUpPendingState(); | 58 SetUpPendingState(false); |
| 58 [controller() showWindow:nil]; | 59 [controller() showWindow:nil]; |
| 59 | 60 |
| 60 // Turn off animations so that closing happens immediately. | 61 // Turn off animations so that closing happens immediately. |
| 61 base::scoped_nsobject<InfoBubbleWindow> window( | 62 base::scoped_nsobject<InfoBubbleWindow> window( |
| 62 [base::mac::ObjCCast<InfoBubbleWindow>([controller() window]) retain]); | 63 [base::mac::ObjCCast<InfoBubbleWindow>([controller() window]) retain]); |
| 63 [window setAllowedAnimations:info_bubble::kAnimateNone]; | 64 [window setAllowedAnimations:info_bubble::kAnimateNone]; |
| 64 | 65 |
| 65 EXPECT_TRUE([window isVisible]); | 66 EXPECT_TRUE([window isVisible]); |
| 66 [controller() viewShouldDismiss]; | 67 [controller() viewShouldDismiss]; |
| 67 EXPECT_FALSE([window isVisible]); | 68 EXPECT_FALSE([window isVisible]); |
| 68 } | 69 } |
| 69 | 70 |
| 70 TEST_F(ManagePasswordsBubbleControllerTest, ManageStateShouldHaveManageView) { | 71 TEST_F(ManagePasswordsBubbleControllerTest, ManageStateShouldHaveManageView) { |
| 71 SetUpManageState(); | 72 SetUpManageState(); |
| 72 EXPECT_EQ([ManagePasswordsBubbleManageViewController class], | 73 EXPECT_EQ([ManagePasswordsBubbleManageViewController class], |
| 73 [[controller() currentController] class]); | 74 [[controller() currentController] class]); |
| 74 } | 75 } |
| 75 | 76 |
| 77 TEST_F(ManagePasswordsBubbleControllerTest, |
| 78 PendingStateShouldHaveUpdatePendingView) { |
| 79 SetUpPendingState(true); |
| 80 EXPECT_EQ([UpdatePendingPasswordViewController class], |
| 81 [[controller() currentController] class]); |
| 82 } |
| 83 |
| 76 } // namespace | 84 } // namespace |
| OLD | NEW |