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/autofill/password_generation_popup_view.h" | 5 #include "chrome/browser/ui/autofill/password_generation_popup_view.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" | 8 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
9 #include "chrome/browser/ui/autofill/password_generation_popup_view_tester.h" | 9 #include "chrome/browser/ui/autofill/password_generation_popup_view_tester.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 ~TestPasswordGenerationPopupController() override {} | 34 ~TestPasswordGenerationPopupController() override {} |
35 | 35 |
36 PasswordGenerationPopupView* view() { | 36 PasswordGenerationPopupView* view() { |
37 return view_; | 37 return view_; |
38 } | 38 } |
39 }; | 39 }; |
40 | 40 |
41 class PasswordGenerationPopupViewTest : public InProcessBrowserTest { | 41 class PasswordGenerationPopupViewTest : public InProcessBrowserTest { |
42 public: | 42 public: |
43 void SetUpOnMainThread() override { | 43 content::WebContents* GetWebContents() { |
44 gfx::NativeView native_view = | 44 return browser()->tab_strip_model()->GetActiveWebContents(); |
45 browser()->tab_strip_model()->GetActiveWebContents()->GetNativeView(); | 45 } |
46 | 46 |
47 controller_ = | 47 gfx::NativeView GetNativeView() { |
48 new TestPasswordGenerationPopupController( | 48 return GetWebContents()->GetNativeView(); |
49 browser()->tab_strip_model()->GetActiveWebContents(), native_view); | |
50 } | 49 } |
51 | 50 |
52 scoped_ptr<PasswordGenerationPopupViewTester> GetViewTester() { | 51 scoped_ptr<PasswordGenerationPopupViewTester> GetViewTester() { |
53 return PasswordGenerationPopupViewTester::For(controller_->view()).Pass(); | 52 return PasswordGenerationPopupViewTester::For(controller_->view()).Pass(); |
54 } | 53 } |
55 | 54 |
56 protected: | 55 protected: |
57 TestPasswordGenerationPopupController* controller_; | 56 TestPasswordGenerationPopupController* controller_; |
58 }; | 57 }; |
59 | 58 |
60 // TODO(gcasto): Enable on Mac when UI is updated. (crbug.com/394303) | 59 // TODO(gcasto): Enable on Mac when UI is updated. (crbug.com/394303) |
61 #if !defined(OS_MACOSX) | 60 #if !defined(OS_MACOSX) |
62 // Regression test for crbug.com/400543. Verifying that moving the mouse in the | 61 // Regression test for crbug.com/400543. Verifying that moving the mouse in the |
63 // editing dialog doesn't crash. | 62 // editing dialog doesn't crash. |
64 IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, | 63 IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, |
65 MouseMovementInEditingPopup) { | 64 MouseMovementInEditingPopup) { |
| 65 controller_ = new autofill::TestPasswordGenerationPopupController( |
| 66 GetWebContents(), GetNativeView()); |
66 controller_->Show(false /* display_password */); | 67 controller_->Show(false /* display_password */); |
67 | 68 |
68 gfx::Point center_point = | 69 gfx::Point center_point = |
69 static_cast<PasswordGenerationPopupController*>( | 70 static_cast<PasswordGenerationPopupController*>( |
70 controller_)->popup_bounds().CenterPoint(); | 71 controller_)->popup_bounds().CenterPoint(); |
71 GetViewTester()->SimulateMouseMovementAt(center_point); | 72 GetViewTester()->SimulateMouseMovementAt(center_point); |
72 | 73 |
73 // Deletes |controller_|. | 74 // Deletes |controller_|. |
74 controller_->HideAndDestroy(); | 75 controller_->HideAndDestroy(); |
75 } | 76 } |
| 77 |
| 78 // Verify that we calling Show() with an invalid container does not crash. |
| 79 // Regression test for crbug.com/439618. |
| 80 IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, |
| 81 InvalidContainerView) { |
| 82 controller_ = new autofill::TestPasswordGenerationPopupController( |
| 83 GetWebContents(), NULL); |
| 84 controller_->Show(true /* display password */); |
| 85 } |
76 #endif | 86 #endif |
77 | 87 |
78 } // namespace autofill | 88 } // namespace autofill |
OLD | NEW |