Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / autofill / password_generation_popup_view_browsertest.cc
blob55eab63bdf320010e80f44c669e3c9f2a3d2ab14
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/autofill/password_generation_popup_view.h"
7 #include "base/strings/string16.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"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/events/event_utils.h"
17 namespace autofill {
19 class TestPasswordGenerationPopupController :
20 public PasswordGenerationPopupControllerImpl {
21 public:
22 TestPasswordGenerationPopupController(content::WebContents* web_contents,
23 gfx::NativeView native_view)
24 : PasswordGenerationPopupControllerImpl(
25 gfx::RectF(0, 0, 10, 10),
26 PasswordForm(),
27 10,
28 nullptr /* PasswordManager*/,
29 nullptr /* PasswordManagerDriver*/,
30 nullptr /* PasswordGenerationPopupObserver*/,
31 web_contents,
32 native_view) {}
34 ~TestPasswordGenerationPopupController() override {}
36 PasswordGenerationPopupView* view() {
37 return view_;
41 class PasswordGenerationPopupViewTest : public InProcessBrowserTest {
42 public:
43 content::WebContents* GetWebContents() {
44 return browser()->tab_strip_model()->GetActiveWebContents();
47 gfx::NativeView GetNativeView() {
48 return GetWebContents()->GetNativeView();
51 scoped_ptr<PasswordGenerationPopupViewTester> GetViewTester() {
52 return PasswordGenerationPopupViewTester::For(controller_->view()).Pass();
55 protected:
56 TestPasswordGenerationPopupController* controller_;
59 // TODO(gcasto): Enable on Mac when UI is updated. (crbug.com/394303)
60 #if !defined(OS_MACOSX)
61 // Regression test for crbug.com/400543. Verifying that moving the mouse in the
62 // editing dialog doesn't crash.
63 IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest,
64 MouseMovementInEditingPopup) {
65 controller_ = new autofill::TestPasswordGenerationPopupController(
66 GetWebContents(), GetNativeView());
67 controller_->Show(false /* display_password */);
69 gfx::Point center_point =
70 static_cast<PasswordGenerationPopupController*>(
71 controller_)->popup_bounds().CenterPoint();
72 GetViewTester()->SimulateMouseMovementAt(center_point);
74 // Deletes |controller_|.
75 controller_->HideAndDestroy();
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 */);
86 #endif
88 } // namespace autofill