| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/command_updater.h" | 13 #include "chrome/browser/command_updater.h" |
| 14 #include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h" | 14 #include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 16 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "ui/base/ime/text_edit_commands.h" | 18 #include "ui/base/ime/text_edit_commands.h" |
| 19 #include "ui/events/event_utils.h" | 19 #include "ui/events/event_utils.h" |
| 20 #include "ui/events/keycodes/dom/dom_code.h" | 20 #include "ui/events/keycodes/dom/dom_code.h" |
| 21 #include "ui/views/controls/textfield/textfield_test_api.h" | 21 #include "ui/views/controls/textfield/textfield_test_api.h" |
| 22 | 22 |
| 23 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 24 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 24 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
| 25 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 25 #include "chrome/browser/chromeos/input_method/mock_input_method_manager_impl.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class TestingOmniboxViewViews : public OmniboxViewViews { | 30 class TestingOmniboxViewViews : public OmniboxViewViews { |
| 31 public: | 31 public: |
| 32 TestingOmniboxViewViews(OmniboxEditController* controller, | 32 TestingOmniboxViewViews(OmniboxEditController* controller, |
| 33 Profile* profile, | 33 Profile* profile, |
| 34 CommandUpdater* command_updater) | 34 CommandUpdater* command_updater) |
| 35 : OmniboxViewViews(controller, profile, command_updater, false, NULL, | 35 : OmniboxViewViews(controller, profile, command_updater, false, NULL, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 ui::TextEditCommand scheduled_text_edit_command() const { | 96 ui::TextEditCommand scheduled_text_edit_command() const { |
| 97 return test_api_->scheduled_text_edit_command(); | 97 return test_api_->scheduled_text_edit_command(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 // testing::Test: | 101 // testing::Test: |
| 102 void SetUp() override { | 102 void SetUp() override { |
| 103 #if defined(OS_CHROMEOS) | 103 #if defined(OS_CHROMEOS) |
| 104 chromeos::input_method::InitializeForTesting( | 104 chromeos::input_method::InitializeForTesting( |
| 105 new chromeos::input_method::MockInputMethodManager); | 105 new chromeos::input_method::MockInputMethodManagerImpl); |
| 106 #endif | 106 #endif |
| 107 omnibox_view_.reset(new TestingOmniboxViewViews( | 107 omnibox_view_.reset(new TestingOmniboxViewViews( |
| 108 &omnibox_edit_controller_, &profile_, &command_updater_)); | 108 &omnibox_edit_controller_, &profile_, &command_updater_)); |
| 109 test_api_.reset(new views::TextfieldTestApi(omnibox_view_.get())); | 109 test_api_.reset(new views::TextfieldTestApi(omnibox_view_.get())); |
| 110 omnibox_view_->Init(); | 110 omnibox_view_->Init(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void TearDown() override { | 113 void TearDown() override { |
| 114 omnibox_view_.reset(); | 114 omnibox_view_.reset(); |
| 115 #if defined(OS_CHROMEOS) | 115 #if defined(OS_CHROMEOS) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 TEST_F(OmniboxViewViewsTest, ScheduledTextEditCommand) { | 156 TEST_F(OmniboxViewViewsTest, ScheduledTextEditCommand) { |
| 157 omnibox_textfield()->SetTextEditCommandForNextKeyEvent( | 157 omnibox_textfield()->SetTextEditCommandForNextKeyEvent( |
| 158 ui::TextEditCommand::MOVE_UP); | 158 ui::TextEditCommand::MOVE_UP); |
| 159 EXPECT_EQ(ui::TextEditCommand::MOVE_UP, scheduled_text_edit_command()); | 159 EXPECT_EQ(ui::TextEditCommand::MOVE_UP, scheduled_text_edit_command()); |
| 160 | 160 |
| 161 ui::KeyEvent up_pressed(ui::ET_KEY_PRESSED, ui::VKEY_UP, 0); | 161 ui::KeyEvent up_pressed(ui::ET_KEY_PRESSED, ui::VKEY_UP, 0); |
| 162 omnibox_textfield()->OnKeyEvent(&up_pressed); | 162 omnibox_textfield()->OnKeyEvent(&up_pressed); |
| 163 EXPECT_EQ(ui::TextEditCommand::INVALID_COMMAND, | 163 EXPECT_EQ(ui::TextEditCommand::INVALID_COMMAND, |
| 164 scheduled_text_edit_command()); | 164 scheduled_text_edit_command()); |
| 165 } | 165 } |
| OLD | NEW |