Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / ui / autofill / password_generation_popup_view_browsertest.cc
blob4e1c1185cafd5c14733acb409ebe7f1e7f9a70cc
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 NULL /* PasswordManager*/,
29 NULL /* PasswordGenerationPopupObserver*/,
30 web_contents,
31 native_view) {}
33 virtual ~TestPasswordGenerationPopupController() {}
35 PasswordGenerationPopupView* view() {
36 return view_;
40 class PasswordGenerationPopupViewTest : public InProcessBrowserTest {
41 public:
42 virtual void SetUpOnMainThread() override {
43 gfx::NativeView native_view =
44 browser()->tab_strip_model()->GetActiveWebContents()->GetNativeView();
46 controller_ =
47 new TestPasswordGenerationPopupController(
48 browser()->tab_strip_model()->GetActiveWebContents(), native_view);
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_->Show(false /* display_password */);
67 gfx::Point center_point =
68 static_cast<PasswordGenerationPopupController*>(
69 controller_)->popup_bounds().CenterPoint();
70 GetViewTester()->SimulateMouseMovementAt(center_point);
72 // Deletes |controller_|.
73 controller_->HideAndDestroy();
75 #endif
77 } // namespace autofill