OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/controls/webview/webview.h" | 5 #include "ui/views/controls/webview/webview.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "content/public/test/test_browser_context.h" | 10 #include "content/public/test/test_browser_context.h" |
| 11 #include "content/public/test/test_browser_thread.h" |
11 #include "ui/base/ime/text_input_focus_manager.h" | 12 #include "ui/base/ime/text_input_focus_manager.h" |
12 #include "ui/base/ui_base_switches.h" | 13 #include "ui/base/ui_base_switches.h" |
13 #include "ui/gl/gl_surface.h" | 14 #include "ui/gl/gl_surface.h" |
14 #include "ui/views/test/webview_test_helper.h" | 15 #include "ui/views/test/webview_test_helper.h" |
15 #include "ui/views/test/widget_test.h" | 16 #include "ui/views/test/widget_test.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 class WebViewInteractiveUiTest : public views::test::WidgetTest { | 20 class WebViewInteractiveUiTest : public views::test::WidgetTest { |
20 public: | 21 public: |
21 WebViewInteractiveUiTest() {} | 22 WebViewInteractiveUiTest() |
| 23 : ui_thread_(content::BrowserThread::UI, base::MessageLoop::current()) {} |
22 | 24 |
23 virtual void SetUp() OVERRIDE { | 25 virtual void SetUp() OVERRIDE { |
24 gfx::GLSurface::InitializeOneOffForTests(); | 26 gfx::GLSurface::InitializeOneOffForTests(); |
25 WidgetTest::SetUp(); | 27 WidgetTest::SetUp(); |
26 } | 28 } |
27 | 29 |
28 protected: | 30 protected: |
29 content::BrowserContext* browser_context() { return &browser_context_; } | 31 content::BrowserContext* browser_context() { return &browser_context_; } |
30 | 32 |
31 private: | 33 private: |
32 content::TestBrowserContext browser_context_; | 34 content::TestBrowserContext browser_context_; |
33 views::WebViewTestHelper webview_test_helper_; | 35 views::WebViewTestHelper webview_test_helper_; |
| 36 content::TestBrowserThread ui_thread_; |
34 | 37 |
35 DISALLOW_COPY_AND_ASSIGN(WebViewInteractiveUiTest); | 38 DISALLOW_COPY_AND_ASSIGN(WebViewInteractiveUiTest); |
36 }; | 39 }; |
37 | 40 |
38 TEST_F(WebViewInteractiveUiTest, TextInputClientIsUpToDate) { | 41 TEST_F(WebViewInteractiveUiTest, TextInputClientIsUpToDate) { |
39 // WebViewInteractiveUiTest.TextInputClientIsUpToDate needs | 42 // WebViewInteractiveUiTest.TextInputClientIsUpToDate needs |
40 // kEnableTextInputFocusManager flag to be enabled. | 43 // kEnableTextInputFocusManager flag to be enabled. |
41 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 44 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
42 cmd_line->AppendSwitch(switches::kEnableTextInputFocusManager); | 45 cmd_line->AppendSwitch(switches::kEnableTextInputFocusManager); |
43 | 46 |
(...skipping 26 matching lines...) Expand all Loading... |
70 ui::TextInputClient* client2 = webview->GetTextInputClient(); | 73 ui::TextInputClient* client2 = webview->GetTextInputClient(); |
71 EXPECT_NE(null_text_input_client, client2); | 74 EXPECT_NE(null_text_input_client, client2); |
72 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client2); | 75 EXPECT_EQ(text_input_focus_manager->GetFocusedTextInputClient(), client2); |
73 EXPECT_NE(client1, client2); | 76 EXPECT_NE(client1, client2); |
74 | 77 |
75 widget->Close(); | 78 widget->Close(); |
76 RunPendingMessages(); | 79 RunPendingMessages(); |
77 } | 80 } |
78 | 81 |
79 } // namespace | 82 } // namespace |
OLD | NEW |