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