| 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> |
| 10 |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 #include "chrome/browser/command_updater.h" | 13 #include "chrome/browser/command_updater.h" |
| 13 #include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h" | 14 #include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
| 18 #include "ui/events/keycodes/dom/dom_code.h" | 19 #include "ui/events/keycodes/dom/dom_code.h" |
| 19 | 20 |
| 20 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 omnibox_view_.reset(); | 109 omnibox_view_.reset(); |
| 109 #if defined(OS_CHROMEOS) | 110 #if defined(OS_CHROMEOS) |
| 110 chromeos::input_method::Shutdown(); | 111 chromeos::input_method::Shutdown(); |
| 111 #endif | 112 #endif |
| 112 } | 113 } |
| 113 | 114 |
| 114 content::TestBrowserThreadBundle thread_bundle_; | 115 content::TestBrowserThreadBundle thread_bundle_; |
| 115 TestingProfile profile_; | 116 TestingProfile profile_; |
| 116 CommandUpdater command_updater_; | 117 CommandUpdater command_updater_; |
| 117 TestingOmniboxEditController omnibox_edit_controller_; | 118 TestingOmniboxEditController omnibox_edit_controller_; |
| 118 scoped_ptr<TestingOmniboxViewViews> omnibox_view_; | 119 std::unique_ptr<TestingOmniboxViewViews> omnibox_view_; |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 // Checks that a single change of the text in the omnibox invokes | 122 // Checks that a single change of the text in the omnibox invokes |
| 122 // only one call to OmniboxViewViews::UpdatePopup(). | 123 // only one call to OmniboxViewViews::UpdatePopup(). |
| 123 TEST_F(OmniboxViewViewsTest, UpdatePopupCall) { | 124 TEST_F(OmniboxViewViewsTest, UpdatePopupCall) { |
| 124 ui::KeyEvent char_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::US_A, 0, | 125 ui::KeyEvent char_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::US_A, 0, |
| 125 ui::DomKey::FromCharacter('a'), | 126 ui::DomKey::FromCharacter('a'), |
| 126 ui::EventTimeForNow()); | 127 ui::EventTimeForNow()); |
| 127 omnibox_textfield()->InsertChar(char_event); | 128 omnibox_textfield()->InsertChar(char_event); |
| 128 omnibox_view()->CheckUpdatePopupCallInfo( | 129 omnibox_view()->CheckUpdatePopupCallInfo( |
| 129 1, base::ASCIIToUTF16("a"), gfx::Range(1)); | 130 1, base::ASCIIToUTF16("a"), gfx::Range(1)); |
| 130 | 131 |
| 131 char_event = | 132 char_event = |
| 132 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_B, ui::DomCode::US_B, 0, | 133 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_B, ui::DomCode::US_B, 0, |
| 133 ui::DomKey::FromCharacter('b'), ui::EventTimeForNow()); | 134 ui::DomKey::FromCharacter('b'), ui::EventTimeForNow()); |
| 134 omnibox_textfield()->InsertChar(char_event); | 135 omnibox_textfield()->InsertChar(char_event); |
| 135 omnibox_view()->CheckUpdatePopupCallInfo( | 136 omnibox_view()->CheckUpdatePopupCallInfo( |
| 136 2, base::ASCIIToUTF16("ab"), gfx::Range(2)); | 137 2, base::ASCIIToUTF16("ab"), gfx::Range(2)); |
| 137 | 138 |
| 138 ui::KeyEvent pressed(ui::ET_KEY_PRESSED, ui::VKEY_BACK, 0); | 139 ui::KeyEvent pressed(ui::ET_KEY_PRESSED, ui::VKEY_BACK, 0); |
| 139 omnibox_textfield()->OnKeyPressed(pressed); | 140 omnibox_textfield()->OnKeyPressed(pressed); |
| 140 omnibox_view()->CheckUpdatePopupCallInfo( | 141 omnibox_view()->CheckUpdatePopupCallInfo( |
| 141 3, base::ASCIIToUTF16("a"), gfx::Range(1)); | 142 3, base::ASCIIToUTF16("a"), gfx::Range(1)); |
| 142 } | 143 } |
| OLD | NEW |