OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/autofill/autofill_dialog_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h" | 10 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 private: | 44 private: |
45 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogViews); | 45 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogViews); |
46 }; | 46 }; |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 class AutofillDialogViewsTest : public TestWithBrowserView { | 50 class AutofillDialogViewsTest : public TestWithBrowserView { |
51 public: | 51 public: |
52 AutofillDialogViewsTest() {} | 52 AutofillDialogViewsTest() {} |
53 virtual ~AutofillDialogViewsTest() {} | 53 ~AutofillDialogViewsTest() override {} |
54 | 54 |
55 // TestWithBrowserView: | 55 // TestWithBrowserView: |
56 virtual void SetUp() override { | 56 void SetUp() override { |
57 TestWithBrowserView::SetUp(); | 57 TestWithBrowserView::SetUp(); |
58 | 58 |
59 view_delegate_.SetProfile(profile()); | 59 view_delegate_.SetProfile(profile()); |
60 | 60 |
61 AddTab(browser(), GURL(url::kAboutBlankURL)); | 61 AddTab(browser(), GURL(url::kAboutBlankURL)); |
62 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 62 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
63 content::WebContents* contents = tab_strip_model->GetWebContentsAt(0); | 63 content::WebContents* contents = tab_strip_model->GetWebContentsAt(0); |
64 ASSERT_TRUE(contents); | 64 ASSERT_TRUE(contents); |
65 view_delegate_.SetWebContents(contents); | 65 view_delegate_.SetWebContents(contents); |
66 | 66 |
67 BrowserView* browser_view = | 67 BrowserView* browser_view = |
68 BrowserView::GetBrowserViewForBrowser(browser()); | 68 BrowserView::GetBrowserViewForBrowser(browser()); |
69 dialog_host_.reset(new web_modal::TestWebContentsModalDialogHost( | 69 dialog_host_.reset(new web_modal::TestWebContentsModalDialogHost( |
70 browser_view->GetWidget()->GetNativeView())); | 70 browser_view->GetWidget()->GetNativeView())); |
71 dialog_delegate_.set_web_contents_modal_dialog_host(dialog_host_.get()); | 71 dialog_delegate_.set_web_contents_modal_dialog_host(dialog_host_.get()); |
72 | 72 |
73 WebContentsModalDialogManager* dialog_manager = | 73 WebContentsModalDialogManager* dialog_manager = |
74 WebContentsModalDialogManager::FromWebContents(contents); | 74 WebContentsModalDialogManager::FromWebContents(contents); |
75 ASSERT_TRUE(dialog_manager); | 75 ASSERT_TRUE(dialog_manager); |
76 dialog_manager->SetDelegate(&dialog_delegate_); | 76 dialog_manager->SetDelegate(&dialog_delegate_); |
77 | 77 |
78 dialog_.reset(new TestAutofillDialogViews(&view_delegate_)); | 78 dialog_.reset(new TestAutofillDialogViews(&view_delegate_)); |
79 dialog_->Show(); | 79 dialog_->Show(); |
80 } | 80 } |
81 | 81 |
82 virtual void TearDown() override { | 82 void TearDown() override { |
83 dialog_->GetWidget()->CloseNow(); | 83 dialog_->GetWidget()->CloseNow(); |
84 dialog_.reset(); | 84 dialog_.reset(); |
85 | 85 |
86 TestWithBrowserView::TearDown(); | 86 TestWithBrowserView::TearDown(); |
87 } | 87 } |
88 | 88 |
89 MockAutofillDialogViewDelegate* delegate() { return &view_delegate_; } | 89 MockAutofillDialogViewDelegate* delegate() { return &view_delegate_; } |
90 | 90 |
91 TestAutofillDialogViews* dialog() { return dialog_.get(); } | 91 TestAutofillDialogViews* dialog() { return dialog_.get(); } |
92 | 92 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 views::FocusManager* focus_manager = dialog()->GetWidget()->GetFocusManager(); | 191 views::FocusManager* focus_manager = dialog()->GetWidget()->GetFocusManager(); |
192 views::View* focused_view = focus_manager->GetFocusedView(); | 192 views::View* focused_view = focus_manager->GetFocusedView(); |
193 ASSERT_STREQ(DecoratedTextfield::kViewClassName, | 193 ASSERT_STREQ(DecoratedTextfield::kViewClassName, |
194 focused_view->GetClassName()); | 194 focused_view->GetClassName()); |
195 EXPECT_FALSE(dialog()->HandleKeyEvent( | 195 EXPECT_FALSE(dialog()->HandleKeyEvent( |
196 static_cast<views::Textfield*>(focused_view), | 196 static_cast<views::Textfield*>(focused_view), |
197 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE))); | 197 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE))); |
198 } | 198 } |
199 | 199 |
200 } // namespace autofill | 200 } // namespace autofill |
OLD | NEW |