Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 18 matching lines...) Expand all Loading... | |
| 29 #include "ui/views/controls/textfield/textfield_test_api.h" | 29 #include "ui/views/controls/textfield/textfield_test_api.h" |
| 30 #include "ui/views/focus/focus_manager.h" | 30 #include "ui/views/focus/focus_manager.h" |
| 31 #include "ui/views/test/focus_manager_test.h" | 31 #include "ui/views/test/focus_manager_test.h" |
| 32 #include "ui/views/test/native_widget_factory.h" | 32 #include "ui/views/test/native_widget_factory.h" |
| 33 #include "ui/views/test/widget_test.h" | 33 #include "ui/views/test/widget_test.h" |
| 34 #include "ui/views/touchui/touch_selection_controller_impl.h" | 34 #include "ui/views/touchui/touch_selection_controller_impl.h" |
| 35 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
| 36 #include "ui/views/window/dialog_delegate.h" | 36 #include "ui/views/window/dialog_delegate.h" |
| 37 #include "ui/wm/public/activation_client.h" | 37 #include "ui/wm/public/activation_client.h" |
| 38 | 38 |
| 39 #if defined(USE_AURA) | |
| 40 #include "ui/aura/window.h" | |
| 41 #include "ui/wm/core/base_focus_rules.h" | |
| 42 #include "ui/wm/core/focus_controller.h" | |
| 43 #endif | |
| 44 | |
| 39 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 40 #include "ui/aura/window.h" | |
| 41 #include "ui/aura/window_tree_host.h" | 46 #include "ui/aura/window_tree_host.h" |
| 42 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 47 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 43 #include "ui/views/win/hwnd_util.h" | 48 #include "ui/views/win/hwnd_util.h" |
| 44 #endif | 49 #endif |
| 45 | 50 |
| 46 namespace views { | 51 namespace views { |
| 47 namespace test { | 52 namespace test { |
| 48 | 53 |
| 49 namespace { | 54 namespace { |
| 50 | 55 |
| (...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1814 | 1819 |
| 1815 widget->GetFocusManager()->UnregisterAccelerators(textfield); | 1820 widget->GetFocusManager()->UnregisterAccelerators(textfield); |
| 1816 | 1821 |
| 1817 ui::KeyEvent key_event2(key_event); | 1822 ui::KeyEvent key_event2(key_event); |
| 1818 widget->OnKeyEvent(&key_event2); | 1823 widget->OnKeyEvent(&key_event2); |
| 1819 EXPECT_FALSE(key_event2.stopped_propagation()); | 1824 EXPECT_FALSE(key_event2.stopped_propagation()); |
| 1820 | 1825 |
| 1821 widget->CloseNow(); | 1826 widget->CloseNow(); |
| 1822 } | 1827 } |
| 1823 | 1828 |
| 1829 #if defined(USE_AURA) | |
| 1830 class TestFocusRules : public wm::BaseFocusRules { | |
| 1831 public: | |
| 1832 TestFocusRules() {} | |
| 1833 ~TestFocusRules() override {} | |
| 1834 | |
| 1835 void set_can_activate(bool can_activate) { can_activate_ = can_activate; } | |
| 1836 | |
| 1837 // wm::BaseFocusRules overrides: | |
| 1838 bool SupportsChildActivation(aura::Window* window) const override { | |
| 1839 return true; | |
| 1840 } | |
| 1841 | |
| 1842 bool CanActivateWindow(aura::Window* window) const override { | |
| 1843 return can_activate_; | |
| 1844 } | |
| 1845 | |
| 1846 private: | |
| 1847 bool can_activate_ = true; | |
| 1848 | |
| 1849 DISALLOW_COPY_AND_ASSIGN(TestFocusRules); | |
| 1850 }; | |
| 1851 | |
| 1852 // (crbug.com/621791) | |
| 1853 #if defined(OS_WIN) | |
| 1854 // TODO(warx): Figure out the reason for the test failing on OS_WIN. | |
| 1855 #define MAYBE_NonActiveWindowRequestImeFocus \ | |
| 1856 DISABLED_NonActiveWindowRequestImeFocus | |
| 1857 #else | |
| 1858 #define MAYBE_NonActiveWindowRequestImeFocus NonActiveWindowRequestImeFocus | |
| 1859 #endif | |
| 1860 TEST_F(WidgetInputMethodInteractiveTest, MAYBE_NonActiveWindowRequestImeFocus) { | |
|
sky
2016/10/19 16:23:32
How come you're grouping this in WidgetInputMethod
Qiang(Joe) Xu
2016/10/20 23:51:51
done
| |
| 1861 TestFocusRules* test_focus_rules = new TestFocusRules; | |
| 1862 std::unique_ptr<wm::FocusController> focus_controller = | |
| 1863 base::MakeUnique<wm::FocusController>(test_focus_rules); | |
| 1864 aura::client::SetActivationClient(GetContext(), focus_controller.get()); | |
| 1865 | |
| 1866 Widget* widget1 = CreateWidget(); | |
| 1867 Textfield* textfield1a = new Textfield; | |
| 1868 widget1->GetRootView()->AddChildView(textfield1a); | |
| 1869 Textfield* textfield1b = new Textfield; | |
| 1870 widget1->GetRootView()->AddChildView(textfield1b); | |
| 1871 | |
| 1872 Widget* widget2 = CreateWidget(); | |
| 1873 Textfield* textfield2 = new Textfield; | |
| 1874 widget2->GetRootView()->AddChildView(textfield2); | |
| 1875 | |
| 1876 ShowSync(widget2); | |
| 1877 textfield2->RequestFocus(); | |
| 1878 EXPECT_TRUE(textfield2->HasFocus()); | |
| 1879 EXPECT_FALSE(textfield1a->HasFocus()); | |
| 1880 EXPECT_FALSE(textfield1b->HasFocus()); | |
| 1881 | |
| 1882 // Don't allow window activation at this step. | |
| 1883 test_focus_rules->set_can_activate(false); | |
| 1884 textfield1a->RequestFocus(); | |
| 1885 EXPECT_TRUE(textfield2->HasFocus()); | |
| 1886 EXPECT_FALSE(textfield1a->HasFocus()); | |
| 1887 EXPECT_FALSE(textfield1b->HasFocus()); | |
| 1888 | |
| 1889 // Allow window activation and |widget1| gets activated at this step, focus | |
| 1890 // should be properly restored. | |
| 1891 test_focus_rules->set_can_activate(true); | |
| 1892 ShowSync(widget1); | |
| 1893 EXPECT_TRUE(textfield1a->HasFocus()); | |
| 1894 EXPECT_FALSE(textfield1b->HasFocus()); | |
| 1895 EXPECT_FALSE(textfield2->HasFocus()); | |
| 1896 | |
| 1897 widget1->Close(); | |
| 1898 widget2->Close(); | |
| 1899 } | |
| 1900 #endif | |
| 1901 | |
| 1824 } // namespace test | 1902 } // namespace test |
| 1825 } // namespace views | 1903 } // namespace views |
| OLD | NEW |