Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 2371113003: Do not give instant focus if a view's toplevelwidget is not active (Closed)
Patch Set: based on sky's comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« chrome/test/BUILD.gn ('K') | « ui/views/widget/root_view_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 Widget* deactivate_widget_ = nullptr; 1691 Widget* deactivate_widget_ = nullptr;
1692 1692
1693 DISALLOW_COPY_AND_ASSIGN(WidgetInputMethodInteractiveTest); 1693 DISALLOW_COPY_AND_ASSIGN(WidgetInputMethodInteractiveTest);
1694 }; 1694 };
1695 1695
1696 // Test input method focus changes affected by top window activaction. 1696 // Test input method focus changes affected by top window activaction.
1697 TEST_F(WidgetInputMethodInteractiveTest, Activation) { 1697 TEST_F(WidgetInputMethodInteractiveTest, Activation) {
1698 Widget* widget = CreateWidget(); 1698 Widget* widget = CreateWidget();
1699 Textfield* textfield = new Textfield; 1699 Textfield* textfield = new Textfield;
1700 widget->GetRootView()->AddChildView(textfield); 1700 widget->GetRootView()->AddChildView(textfield);
1701 ShowSync(widget);
1701 textfield->RequestFocus(); 1702 textfield->RequestFocus();
1702 1703
1703 ShowSync(widget);
1704
1705 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, 1704 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT,
1706 widget->GetInputMethod()->GetTextInputType()); 1705 widget->GetInputMethod()->GetTextInputType());
1707 1706
1708 DeactivateSync(widget); 1707 DeactivateSync(widget);
1709 1708
1710 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, 1709 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
1711 widget->GetInputMethod()->GetTextInputType()); 1710 widget->GetInputMethod()->GetTextInputType());
1712 widget->CloseNow(); 1711 widget->CloseNow();
1713 } 1712 }
1714 1713
(...skipping 23 matching lines...) Expand all
1738 DeactivateSync(widget); 1737 DeactivateSync(widget);
1739 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, 1738 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
1740 widget->GetInputMethod()->GetTextInputType()); 1739 widget->GetInputMethod()->GetTextInputType());
1741 1740
1742 ActivateSync(widget); 1741 ActivateSync(widget);
1743 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, 1742 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD,
1744 widget->GetInputMethod()->GetTextInputType()); 1743 widget->GetInputMethod()->GetTextInputType());
1745 1744
1746 DeactivateSync(widget); 1745 DeactivateSync(widget);
1747 textfield1->RequestFocus(); 1746 textfield1->RequestFocus();
1747 #if defined(OS_MACOSX)
1748 // TODO(warx): WidgetActivationWaiter has a check in ctor.
1749 // Remove ActivateSync(widget) once crbug.com/650859 is fixed.
1748 ActivateSync(widget); 1750 ActivateSync(widget);
1751 #endif
1749 EXPECT_TRUE(widget->IsActive()); 1752 EXPECT_TRUE(widget->IsActive());
1750 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, 1753 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT,
1751 widget->GetInputMethod()->GetTextInputType()); 1754 widget->GetInputMethod()->GetTextInputType());
1752 #endif 1755 #endif
1753 widget->CloseNow(); 1756 widget->CloseNow();
1754 } 1757 }
1755 1758
1756 // Test input method focus changes affected by focus changes cross 2 windows 1759 // Test input method focus changes affected by focus changes cross 2 windows
1757 // which shares the same top window. 1760 // which shares the same top window.
1758 TEST_F(WidgetInputMethodInteractiveTest, TwoWindows) { 1761 TEST_F(WidgetInputMethodInteractiveTest, TwoWindows) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 1862
1860 ui::KeyEvent key_event2(key_event); 1863 ui::KeyEvent key_event2(key_event);
1861 widget->OnKeyEvent(&key_event2); 1864 widget->OnKeyEvent(&key_event2);
1862 EXPECT_FALSE(key_event2.stopped_propagation()); 1865 EXPECT_FALSE(key_event2.stopped_propagation());
1863 1866
1864 widget->CloseNow(); 1867 widget->CloseNow();
1865 } 1868 }
1866 1869
1867 } // namespace test 1870 } // namespace test
1868 } // namespace views 1871 } // namespace views
OLDNEW
« chrome/test/BUILD.gn ('K') | « ui/views/widget/root_view_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698