| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/passwords/account_chooser_view_controller.h" | 5 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> |
| 8 |
| 7 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 10 #import "chrome/browser/ui/cocoa/passwords/autosignin_prompt_view_controller.h" | 12 #import "chrome/browser/ui/cocoa/passwords/autosignin_prompt_view_controller.h" |
| 11 #include "chrome/browser/ui/passwords/password_dialog_controller.h" | 13 #include "chrome/browser/ui/passwords/password_dialog_controller.h" |
| 12 #include "components/autofill/core/common/password_form.h" | 14 #include "components/autofill/core/common/password_form.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #import "ui/events/test/cocoa_test_event_utils.h" |
| 15 | 18 |
| 16 | 19 |
| 17 namespace { | 20 namespace { |
| 18 | 21 |
| 19 const char kDialogTitle[] = "Auto signin"; | 22 const char kDialogTitle[] = "Auto signin"; |
| 20 const char kDialogText[] = "bla bla"; | 23 const char kDialogText[] = "bla bla"; |
| 21 | 24 |
| 22 class PasswordDialogControllerMock : public PasswordDialogController { | 25 class PasswordDialogControllerMock : public PasswordDialogController { |
| 23 public: | 26 public: |
| 24 MOCK_CONST_METHOD0(GetLocalForms, const FormsVector&()); | 27 MOCK_CONST_METHOD0(GetLocalForms, const FormsVector&()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 TEST_F(AutoSigninPromptViewControllerTest, ClosePromptAndHandleClick) { | 116 TEST_F(AutoSigninPromptViewControllerTest, ClosePromptAndHandleClick) { |
| 114 // A user may press mouse down, some navigation closes the dialog, mouse up | 117 // A user may press mouse down, some navigation closes the dialog, mouse up |
| 115 // still sends the action. The view should not crash. | 118 // still sends the action. The view should not crash. |
| 116 SetUpAutosigninFirstRun(); | 119 SetUpAutosigninFirstRun(); |
| 117 [view_controller() setBridge:nil]; | 120 [view_controller() setBridge:nil]; |
| 118 [view_controller().contentText clickedOnLink:@"" atIndex:0]; | 121 [view_controller().contentText clickedOnLink:@"" atIndex:0]; |
| 119 [view_controller().okButton performClick:nil]; | 122 [view_controller().okButton performClick:nil]; |
| 120 [view_controller().turnOffButton performClick:nil]; | 123 [view_controller().turnOffButton performClick:nil]; |
| 121 } | 124 } |
| 122 | 125 |
| 126 TEST_F(AutoSigninPromptViewControllerTest, CloseOnEsc) { |
| 127 SetUpAutosigninFirstRun(); |
| 128 EXPECT_CALL(*this, OnPerformClose()); |
| 129 [[view_controller() view] |
| 130 performKeyEquivalent:cocoa_test_event_utils::KeyEventWithKeyCode( |
| 131 kVK_Escape, '\e', NSKeyDown, 0)]; |
| 132 } |
| 133 |
| 123 } // namespace | 134 } // namespace |
| OLD | NEW |