| 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 #import "chrome/browser/ui/cocoa/autofill/password_generation_popup_view_cocoa.h
" | 5 #import "chrome/browser/ui/cocoa/autofill/password_generation_popup_view_cocoa.h
" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 10 |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 13 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 13 #include "components/autofill/core/browser/suggestion.h" | 14 #include "components/autofill/core/browser/suggestion.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
| 17 #include "ui/gfx/font_list.h" | 18 #include "ui/gfx/font_list.h" |
| 18 #include "ui/gfx/geometry/rect_f.h" | 19 #include "ui/gfx/geometry/rect_f.h" |
| 19 #include "ui/gfx/range/range.h" | 20 #include "ui/gfx/range/range.h" |
| 20 | 21 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 initWithController:mock_controller_.get() | 89 initWithController:mock_controller_.get() |
| 89 frame:NSZeroRect]); | 90 frame:NSZeroRect]); |
| 90 | 91 |
| 91 NSView* contentView = [test_window() contentView]; | 92 NSView* contentView = [test_window() contentView]; |
| 92 [contentView addSubview:view_]; | 93 [contentView addSubview:view_]; |
| 93 EXPECT_CALL(*mock_controller_, container_view()) | 94 EXPECT_CALL(*mock_controller_, container_view()) |
| 94 .WillRepeatedly(Return(contentView)); | 95 .WillRepeatedly(Return(contentView)); |
| 95 } | 96 } |
| 96 | 97 |
| 97 base::string16 password_; | 98 base::string16 password_; |
| 98 scoped_ptr<MockPasswordGenerationPopupController> mock_controller_; | 99 std::unique_ptr<MockPasswordGenerationPopupController> mock_controller_; |
| 99 base::scoped_nsobject<PasswordGenerationPopupViewCocoa> view_; | 100 base::scoped_nsobject<PasswordGenerationPopupViewCocoa> view_; |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 TEST_VIEW(PasswordGenerationPopupViewCocoaTest, view_); | 103 TEST_VIEW(PasswordGenerationPopupViewCocoaTest, view_); |
| 103 | 104 |
| 104 TEST_F(PasswordGenerationPopupViewCocoaTest, ShowAndHide) { | 105 TEST_F(PasswordGenerationPopupViewCocoaTest, ShowAndHide) { |
| 105 // Verify that the view fetches a password from the controller. | 106 // Verify that the view fetches a password from the controller. |
| 106 EXPECT_CALL(*mock_controller_, password()).Times(AtLeast(1)) | 107 EXPECT_CALL(*mock_controller_, password()).Times(AtLeast(1)) |
| 107 .WillRepeatedly(Return(password_)); | 108 .WillRepeatedly(Return(password_)); |
| 108 | 109 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 119 // popup is hidden. | 120 // popup is hidden. |
| 120 TEST_F(PasswordGenerationPopupViewCocoaTest, ControllerDestroyed) { | 121 TEST_F(PasswordGenerationPopupViewCocoaTest, ControllerDestroyed) { |
| 121 [view_ showPopup]; | 122 [view_ showPopup]; |
| 122 mock_controller_.reset(); | 123 mock_controller_.reset(); |
| 123 [view_ controllerDestroyed]; | 124 [view_ controllerDestroyed]; |
| 124 [view_ display]; | 125 [view_ display]; |
| 125 [view_ hidePopup]; | 126 [view_ hidePopup]; |
| 126 } | 127 } |
| 127 | 128 |
| 128 } // namespace | 129 } // namespace |
| OLD | NEW |