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 "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/omnibox/location_bar.h" | 11 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 11 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 12 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 12 #include "chrome/browser/ui/view_ids.h" | 13 #include "chrome/browser/ui/view_ids.h" |
| 13 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/interactive_test_utils.h" | 17 #include "chrome/test/base/interactive_test_utils.h" |
| 17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 18 #include "ui/aura/test/event_generator.h" | 19 #include "ui/aura/test/event_generator.h" |
| 19 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 20 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
| 21 #include "ui/base/clipboard/clipboard.h" | 22 #include "ui/base/clipboard/clipboard.h" |
| 22 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 23 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 23 #include "ui/base/test/ui_controls.h" | 24 #include "ui/base/test/ui_controls.h" |
| 25 #include "ui/base/ui_base_switches.h" | |
| 24 #include "ui/events/event_processor.h" | 26 #include "ui/events/event_processor.h" |
| 27 #include "ui/views/controls/textfield/textfield_test_api.h" | |
| 25 | 28 |
| 26 class OmniboxViewViewsTest : public InProcessBrowserTest { | 29 class OmniboxViewViewsTest : public InProcessBrowserTest { |
| 27 protected: | 30 protected: |
| 28 OmniboxViewViewsTest() {} | 31 OmniboxViewViewsTest() {} |
| 29 | 32 |
| 30 static void GetOmniboxViewForBrowser(const Browser* browser, | 33 static void GetOmniboxViewForBrowser(const Browser* browser, |
| 31 OmniboxView** omnibox_view) { | 34 OmniboxView** omnibox_view) { |
| 32 BrowserWindow* window = browser->window(); | 35 BrowserWindow* window = browser->window(); |
| 33 ASSERT_TRUE(window); | 36 ASSERT_TRUE(window); |
| 34 LocationBar* location_bar = window->GetLocationBar(); | 37 LocationBar* location_bar = window->GetLocationBar(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 | 285 |
| 283 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, BackgroundIsOpaque) { | 286 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, BackgroundIsOpaque) { |
| 284 // The omnibox text should be rendered on an opaque background. Otherwise, we | 287 // The omnibox text should be rendered on an opaque background. Otherwise, we |
| 285 // can't use subpixel rendering. | 288 // can't use subpixel rendering. |
| 286 BrowserWindowTesting* window = browser()->window()->GetBrowserWindowTesting(); | 289 BrowserWindowTesting* window = browser()->window()->GetBrowserWindowTesting(); |
| 287 ASSERT_TRUE(window); | 290 ASSERT_TRUE(window); |
| 288 OmniboxViewViews* view = window->GetLocationBarView()->omnibox_view(); | 291 OmniboxViewViews* view = window->GetLocationBarView()->omnibox_view(); |
| 289 ASSERT_TRUE(view); | 292 ASSERT_TRUE(view); |
| 290 EXPECT_FALSE(view->GetRenderText()->background_is_transparent()); | 293 EXPECT_FALSE(view->GetRenderText()->background_is_transparent()); |
| 291 } | 294 } |
| 295 | |
| 296 // Tests if executing a command hides touch editing handles. | |
| 297 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, | |
| 298 DeactivateTouchEditingOnExecuteCommand) { | |
| 299 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing); | |
| 300 | |
| 301 OmniboxView* view = NULL; | |
| 302 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); | |
| 303 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); | |
| 304 views::TextfieldTestApi textfield_test_api(omnibox_view_views); | |
| 305 | |
| 306 // Put a URL on the clipboard. It is written to the clipboard upon destruction | |
| 307 // of the writer. | |
| 308 { | |
| 309 ui::ScopedClipboardWriter clipboard_writer( | |
|
sky
2014/05/21 16:20:45
Does this need to be in interactive ui tests since
mohsen
2014/05/21 19:54:28
This file is actually part of interactive_ui_tests
| |
| 310 ui::Clipboard::GetForCurrentThread(), | |
| 311 ui::CLIPBOARD_TYPE_COPY_PASTE); | |
| 312 clipboard_writer.WriteURL(base::ASCIIToUTF16("http://www.example.com/")); | |
| 313 } | |
| 314 | |
| 315 // Tap to activate touch editing. | |
| 316 gfx::Point omnibox_center = | |
| 317 omnibox_view_views->GetBoundsInScreen().CenterPoint(); | |
| 318 Tap(omnibox_center, omnibox_center); | |
| 319 EXPECT_TRUE(textfield_test_api.touch_selection_controller()); | |
| 320 | |
| 321 // Execute a command and check if it deactivate touch editing. Paste & Go is | |
| 322 // chosen since it is specific to Omnibox and its execution wouldn't be | |
| 323 // delgated to the base Textfield class. | |
| 324 omnibox_view_views->ExecuteCommand(IDS_PASTE_AND_GO, ui::EF_NONE); | |
| 325 EXPECT_FALSE(textfield_test_api.touch_selection_controller()); | |
| 326 } | |
| OLD | NEW |