Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/ui/browser_focus_uitest.cc

Issue 11414223: Move the test functions that deal with focus to interactive_ui_tets_utils.h and into the interactiv… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_commands.h" 16 #include "chrome/browser/ui/browser_commands.h"
17 #include "chrome/browser/ui/browser_tabstrip.h" 17 #include "chrome/browser/ui/browser_tabstrip.h"
18 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/chrome_pages.h" 19 #include "chrome/browser/ui/chrome_pages.h"
20 #include "chrome/browser/ui/omnibox/location_bar.h"
21 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
22 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
23 #include "chrome/browser/ui/omnibox/omnibox_view.h"
20 #include "chrome/browser/ui/tab_contents/tab_contents.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/browser/ui/view_ids.h" 26 #include "chrome/browser/ui/view_ids.h"
23 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
30 #include "chrome/test/base/interactive_test_utils.h"
26 #include "chrome/test/base/in_process_browser_test.h" 31 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/ui_test_utils.h" 32 #include "chrome/test/base/ui_test_utils.h"
28 #include "content/public/browser/interstitial_page.h" 33 #include "content/public/browser/interstitial_page.h"
29 #include "content/public/browser/interstitial_page_delegate.h" 34 #include "content/public/browser/interstitial_page_delegate.h"
30 #include "content/public/browser/notification_service.h" 35 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/render_view_host.h" 36 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/render_widget_host_view.h" 37 #include "content/public/browser/render_widget_host_view.h"
33 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
34 #include "content/public/browser/web_contents_view.h" 39 #include "content/public/browser/web_contents_view.h"
35 #include "content/public/test/browser_test_utils.h" 40 #include "content/public/test/browser_test_utils.h"
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 &chrome::GetActiveWebContents(browser())->GetController())); 920 &chrome::GetActiveWebContents(browser())->GetController()));
916 chrome::Reload(browser(), CURRENT_TAB); 921 chrome::Reload(browser(), CURRENT_TAB);
917 observer.Wait(); 922 observer.Wait();
918 } 923 }
919 924
920 // Focus should now be on the tab contents. 925 // Focus should now be on the tab contents.
921 chrome::ShowDownloads(browser()); 926 chrome::ShowDownloads(browser());
922 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 927 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
923 } 928 }
924 929
930 // Tests that when a new tab is opened from the omnibox, the focus is moved from
931 // the omnibox for the current tab.
932 IN_PROC_BROWSER_TEST_F(BrowserFocusTest,
933 NavigateFromOmniboxIntoNewTab) {
934 GURL url("http://www.google.com/");
935 GURL url2("http://maps.google.com/");
936
937 // Navigate to url.
938 chrome::NavigateParams p(browser(), url, content::PAGE_TRANSITION_LINK);
939 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
940 p.disposition = CURRENT_TAB;
941 chrome::Navigate(&p);
942
943 // Focus the omnibox.
944 chrome::FocusLocationBar(browser());
945
946 OmniboxEditController* controller =
947 browser()->window()->GetLocationBar()->GetLocationEntry()->model()->
948 controller();
949
950 // Simulate an alt-enter.
951 controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB,
952 content::PAGE_TRANSITION_TYPED, GURL());
953
954 // Make sure the second tab is selected.
955 EXPECT_EQ(1, browser()->active_index());
956
957 // The tab contents should have the focus in the second tab.
958 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
959
960 // Go back to the first tab. The focus should not be in the omnibox.
961 chrome::SelectPreviousTab(browser());
962 EXPECT_EQ(0, browser()->active_index());
963 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
964 VIEW_ID_LOCATION_BAR));
965 }
966
925 } // namespace 967 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698