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 "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/search_engines/template_url_service_factory.h" | 8 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/location_bar/location_bar.h" | 12 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 13 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 13 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 14 #include "chrome/browser/ui/view_ids.h" | 14 #include "chrome/browser/ui/view_ids.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 20 #include "chrome/test/base/interactive_test_utils.h" | 20 #include "chrome/test/base/interactive_test_utils.h" |
| 21 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
| 22 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 22 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 23 #include "ui/base/ime/text_input_focus_manager.h" | |
| 24 #include "ui/base/test/ui_controls.h" | 23 #include "ui/base/test/ui_controls.h" |
| 25 #include "ui/base/ui_base_switches.h" | 24 #include "ui/base/ui_base_switches.h" |
| 26 #include "ui/events/event_processor.h" | 25 #include "ui/events/event_processor.h" |
| 27 #include "ui/events/event_utils.h" | 26 #include "ui/events/event_utils.h" |
| 28 #include "ui/events/test/event_generator.h" | 27 #include "ui/events/test/event_generator.h" |
| 29 #include "ui/views/controls/textfield/textfield_test_api.h" | 28 #include "ui/views/controls/textfield/textfield_test_api.h" |
| 29 #include "ui/views/ime/input_method.h" | |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 void SetClipboardText(ui::ClipboardType type, const std::string& text) { | 33 void SetClipboardText(ui::ClipboardType type, const std::string& text) { |
| 34 ui::ScopedClipboardWriter(type).WriteText(base::ASCIIToUTF16(text)); | 34 ui::ScopedClipboardWriter(type).WriteText(base::ASCIIToUTF16(text)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 class OmniboxViewViewsTest : public InProcessBrowserTest { | 39 class OmniboxViewViewsTest : public InProcessBrowserTest { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 EXPECT_TRUE(textfield_test_api.touch_selection_controller()); | 369 EXPECT_TRUE(textfield_test_api.touch_selection_controller()); |
| 370 | 370 |
| 371 // Execute a command and check if it deactivate touch editing. Paste & Go is | 371 // Execute a command and check if it deactivate touch editing. Paste & Go is |
| 372 // chosen since it is specific to Omnibox and its execution wouldn't be | 372 // chosen since it is specific to Omnibox and its execution wouldn't be |
| 373 // delgated to the base Textfield class. | 373 // delgated to the base Textfield class. |
| 374 omnibox_view_views->ExecuteCommand(IDS_PASTE_AND_GO, ui::EF_NONE); | 374 omnibox_view_views->ExecuteCommand(IDS_PASTE_AND_GO, ui::EF_NONE); |
| 375 EXPECT_FALSE(textfield_test_api.touch_selection_controller()); | 375 EXPECT_FALSE(textfield_test_api.touch_selection_controller()); |
| 376 } | 376 } |
| 377 | 377 |
| 378 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, FocusedTextInputClient) { | 378 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, FocusedTextInputClient) { |
| 379 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
| 380 cmd_line->AppendSwitch(switches::kEnableTextInputFocusManager); | |
| 381 | |
| 382 // TODO(yukishiino): The following call to FocusLocationBar is not necessary | |
| 383 // if the flag is enabled by default. Remove the call once the transition to | |
| 384 // TextInputFocusManager completes. | |
| 385 chrome::FocusLocationBar(browser()); | 379 chrome::FocusLocationBar(browser()); |
| 386 OmniboxView* view = NULL; | 380 OmniboxView* view = NULL; |
| 387 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); | 381 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); |
| 388 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); | 382 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); |
| 389 ui::TextInputFocusManager* text_input_focus_manager = | 383 views::InputMethod* input_method = |
| 390 ui::TextInputFocusManager::GetInstance(); | 384 omnibox_view_views->GetWidget()->GetInputMethod(); |
| 391 EXPECT_EQ(omnibox_view_views->GetTextInputClient(), | 385 EXPECT_EQ(omnibox_view_views, input_method->GetTextInputClient()); |
|
Yuki
2015/06/15 06:14:30
nit: better explicitly write as:
omnibox_view_vi
Shu Chen
2015/06/15 06:24:35
Done.
| |
| 392 text_input_focus_manager->GetFocusedTextInputClient()); | |
| 393 } | 386 } |
| OLD | NEW |