18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/basictypes.h" 88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/compiler_specific.h" 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h" 118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/ui/tabs/tab_strip_model.h" 121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chrome/browser/ui/views/autofill/decorated_textfield.h" 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/ui/views/frame/browser_view.h" 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/ui/views/frame/test_with_browser_view.h" 158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "components/web_modal/test_web_contents_modal_dialog_host.h" 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "components/web_modal/test_web_contents_modal_dialog_manager_delegate.h" 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "components/web_modal/web_contents_modal_dialog_manager.h" 18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "content/public/common/url_constants.h" 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "testing/gmock/include/gmock/gmock.h" 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ui/views/controls/webview/webview.h" 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ui/views/widget/widget.h" 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace autofill { 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace { 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)using testing::Return; 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)using web_modal::WebContentsModalDialogManager; 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// A views implementation of the Autofill dialog with slightly more testability. 328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class TestAutofillDialogViews : public AutofillDialogViews { 338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) explicit TestAutofillDialogViews(AutofillDialogViewDelegate* delegate) 358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) : AutofillDialogViews(delegate) {} 368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~TestAutofillDialogViews() {} 378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) using AutofillDialogViews::GetLoadingShieldForTesting; 398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) using AutofillDialogViews::GetSignInWebViewForTesting; 408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) using AutofillDialogViews::GetNotificationAreaForTesting; 418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) using AutofillDialogViews::GetScrollableAreaForTesting; 428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogViews); 458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace 488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class AutofillDialogViewsTest : public TestWithBrowserView { 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) AutofillDialogViewsTest() {} 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~AutofillDialogViewsTest() {} 538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // TestWithBrowserView: 558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetUp() OVERRIDE { 568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TestWithBrowserView::SetUp(); 578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) view_delegate_.SetProfile(profile()); 591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 60f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) AddTab(browser(), GURL(url::kAboutBlankURL)); 618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TabStripModel* tab_strip_model = browser()->tab_strip_model(); 628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) content::WebContents* contents = tab_strip_model->GetWebContentsAt(0); 638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ASSERT_TRUE(contents); 648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) view_delegate_.SetWebContents(contents); 658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) BrowserView* browser_view = 678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) BrowserView::GetBrowserViewForBrowser(browser()); 688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) dialog_host_.reset(new web_modal::TestWebContentsModalDialogHost( 698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) browser_view->GetWidget()->GetNativeView())); 708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) dialog_delegate_.set_web_contents_modal_dialog_host(dialog_host_.get()); 718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) WebContentsModalDialogManager* dialog_manager = 738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) WebContentsModalDialogManager::FromWebContents(contents); 748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ASSERT_TRUE(dialog_manager); 758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) dialog_manager->SetDelegate(&dialog_delegate_); 768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) dialog_.reset(new TestAutofillDialogViews(&view_delegate_)); 788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) dialog_->Show(); 798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void TearDown() OVERRIDE { 828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) dialog_->GetWidget()->CloseNow(); 831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dialog_.reset(); 848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TestWithBrowserView::TearDown(); 868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) MockAutofillDialogViewDelegate* delegate() { return &view_delegate_; } 891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) TestAutofillDialogViews* dialog() { return dialog_.get(); } 918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void SetSectionsFocusable() { 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dialog()->GetLoadingShieldForTesting()->SetFocusable(true); 951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // The sign in web view is not focusable until a web contents is created. 961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // TODO(dbeam): figure out how to create a web contents on the right thread. 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dialog()->GetNotificationAreaForTesting()->SetFocusable(true); 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dialog()->GetScrollableAreaForTesting()->SetFocusable(true); 998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 1028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Fake dialog delegate and host to isolate test behavior. 1038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) web_modal::TestWebContentsModalDialogManagerDelegate dialog_delegate_; 1048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<web_modal::TestWebContentsModalDialogHost> dialog_host_; 1058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1068bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Mock view delegate as this file only tests the view. 1078bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) testing::NiceMock<MockAutofillDialogViewDelegate> view_delegate_; 1088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_ptr<TestAutofillDialogViews> dialog_; 1108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(AutofillDialogViewsTest, InitialFocus) { 1131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) views::FocusManager* focus_manager = dialog()->GetWidget()->GetFocusManager(); 1141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) views::View* focused_view = focus_manager->GetFocusedView(); 1151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_STREQ(DecoratedTextfield::kViewClassName, 1161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) focused_view->GetClassName()); 1171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 1188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(AutofillDialogViewsTest, SignInFocus) { 1201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) SetSectionsFocusable(); 1218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) views::View* loading_shield = dialog()->GetLoadingShieldForTesting(); 1238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) views::View* sign_in_web_view = dialog()->GetSignInWebViewForTesting(); 1248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) views::View* notification_area = dialog()->GetNotificationAreaForTesting(); 1258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) views::View* scrollable_area = dialog()->GetScrollableAreaForTesting(); 1268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dialog()->ShowSignIn(); 1288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // The sign in view should be the only showing and focusable view. 1301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_TRUE(sign_in_web_view->IsFocusable()); 1311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(loading_shield->IsFocusable()); 1321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(notification_area->IsFocusable()); 1331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(scrollable_area->IsFocusable()); 1348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_CALL(*delegate(), ShouldShowSpinner()).WillRepeatedly(Return(false)); 1361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dialog()->HideSignIn(); 1371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Hide sign in while not loading Wallet items as if the user clicked "Back". 1391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_TRUE(notification_area->IsFocusable()); 1401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_TRUE(scrollable_area->IsFocusable()); 1418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_FALSE(loading_shield->IsFocusable()); 1421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(sign_in_web_view->IsFocusable()); 1438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dialog()->ShowSignIn(); 1458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_TRUE(sign_in_web_view->IsFocusable()); 1471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(loading_shield->IsFocusable()); 1488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_FALSE(notification_area->IsFocusable()); 1491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(scrollable_area->IsFocusable()); 1508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_CALL(*delegate(), ShouldShowSpinner()).WillRepeatedly(Return(true)); 1521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dialog()->HideSignIn(); 1531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Hide sign in while pretending to load Wallet data. 1551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_TRUE(loading_shield->IsFocusable()); 1561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(notification_area->IsFocusable()); 1578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_FALSE(scrollable_area->IsFocusable()); 1581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(sign_in_web_view->IsFocusable()); 1598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(AutofillDialogViewsTest, LoadingFocus) { 1628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SetSectionsFocusable(); 1638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) views::View* loading_shield = dialog()->GetLoadingShieldForTesting(); 1658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) views::View* sign_in_web_view = dialog()->GetSignInWebViewForTesting(); 1668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) views::View* notification_area = dialog()->GetNotificationAreaForTesting(); 1678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) views::View* scrollable_area = dialog()->GetScrollableAreaForTesting(); 1688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Pretend as if loading Wallet data. 1701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_CALL(*delegate(), ShouldShowSpinner()).WillRepeatedly(Return(true)); 1711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dialog()->UpdateAccountChooser(); 1721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_TRUE(loading_shield->IsFocusable()); 1741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(notification_area->IsFocusable()); 1751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(scrollable_area->IsFocusable()); 1761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(sign_in_web_view->IsFocusable()); 1771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Pretend as if Wallet data has finished loading. 1791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_CALL(*delegate(), ShouldShowSpinner()).WillRepeatedly(Return(false)); 1801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) dialog()->UpdateAccountChooser(); 1818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_TRUE(notification_area->IsFocusable()); 1831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_TRUE(scrollable_area->IsFocusable()); 1841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(loading_shield->IsFocusable()); 1851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(sign_in_web_view->IsFocusable()); 1868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 188a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)TEST_F(AutofillDialogViewsTest, ImeEventDoesntCrash) { 189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // IMEs create synthetic events with no backing native event. 190a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) views::FocusManager* focus_manager = dialog()->GetWidget()->GetFocusManager(); 191a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) views::View* focused_view = focus_manager->GetFocusedView(); 192a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_STREQ(DecoratedTextfield::kViewClassName, 193a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) focused_view->GetClassName()); 194a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_FALSE(dialog()->HandleKeyEvent( 195a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) static_cast<views::Textfield*>(focused_view), 1965f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE))); 197a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 198a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace autofill 200