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