diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-17 22:25:17 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-17 22:25:17 +0000 |
commit | b982188ff9d8efc4e9ed40cc00c440e7b622a6be (patch) | |
tree | e9af1636139e36edbe68f9c05c5dc3efbe97b577 /chrome | |
parent | 57c4b8582403c0afe4cdae1996cf9111e824c40d (diff) | |
download | chromium_src-b982188ff9d8efc4e9ed40cc00c440e7b622a6be.zip chromium_src-b982188ff9d8efc4e9ed40cc00c440e7b622a6be.tar.gz chromium_src-b982188ff9d8efc4e9ed40cc00c440e7b622a6be.tar.bz2 |
Begin to port browser focus tests to linux.
TEST=interactive ui tests builds and runs and BrowserFocusTest.TabInitialFocus passes
Review URL: http://codereview.chromium.org/172059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23585 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 68 | ||||
-rw-r--r-- | chrome/chrome.gyp | 208 |
2 files changed, 178 insertions, 98 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index 853f424..39d5e18 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -19,6 +19,10 @@ #include "views/view.h" #include "views/window/window.h" +#if defined(OS_LINUX) +#include "chrome/browser/gtk/view_id_util.h" +#endif + namespace { // The delay waited in some cases where we don't have a notifications for an @@ -36,6 +40,46 @@ class BrowserFocusTest : public InProcessBrowserTest { set_show_window(true); EnableDOMAutomation(); } + + void CheckViewHasFocus(ViewID vid) { + BrowserWindow* browser_window = browser()->window(); + ASSERT_TRUE(browser_window); + gfx::NativeWindow window = browser_window->GetNativeHandle(); + ASSERT_TRUE(window); +#if defined(OS_WIN) + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManagerForNativeView(window); + ASSERT_TRUE(focus_manager); + EXPECT_EQ(reinterpret_cast<views::View*>(browser_window)->GetViewByID(vid), + focus_manager->GetFocusedView()); +#elif defined(OS_LINUX) + GtkWidget* widget = ViewIDUtil::GetWidget(GTK_WIDGET(window), vid); + ASSERT_TRUE(widget); + EXPECT_TRUE(WidgetInFocusChain(GTK_WIDGET(window), widget)); +#else + NOTIMPLEMENTED(); +#endif + } + + private: +#if defined(OS_LINUX) + // Check if the focused widget for |root| is |target| or a child of |target|. + static bool WidgetInFocusChain(GtkWidget* root, GtkWidget* target) { + GtkWidget* iter = root; + + while (iter) { + if (iter == target) + return true; + + if (!GTK_IS_CONTAINER(iter)) + return false; + + iter = GTK_CONTAINER(iter)->focus_child; + } + + return false; + } +#endif }; class TestInterstitialPage : public InterstitialPage { @@ -94,8 +138,10 @@ class TestInterstitialPage : public InterstitialPage { std::string dom_response_; }; + } // namespace +#if defined(OS_WIN) IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) { HTTPTestServer* server = StartHTTPServer(); @@ -605,39 +651,30 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { ASSERT_TRUE(focused_view != NULL); EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, focused_view->GetID()); } +#endif // defined(OS_WIN) // Makes sure the focus is in the right location when opening the different // types of tabs. IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) { - HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle()); - BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(hwnd); - ASSERT_TRUE(browser_view); - views::FocusManager* focus_manager = - views::FocusManager::GetFocusManagerForNativeView(hwnd); - ASSERT_TRUE(focus_manager); - // Open the history tab, focus should be on the tab contents. browser()->ShowHistoryTab(); - EXPECT_EQ(browser_view->GetTabContentsContainerView(), - focus_manager->GetFocusedView()); + CheckViewHasFocus(VIEW_ID_TAB_CONTAINER); // Open the new tab, focus should be on the location bar. browser()->NewTab(); - EXPECT_EQ(browser_view->GetLocationBarView(), - focus_manager->GetFocusedView()); + CheckViewHasFocus(VIEW_ID_LOCATION_BAR); // Open the download tab, focus should be on the tab contents. browser()->ShowDownloadsTab(); - EXPECT_EQ(browser_view->GetTabContentsContainerView(), - focus_manager->GetFocusedView()); + CheckViewHasFocus(VIEW_ID_TAB_CONTAINER); // Open about:blank, focus should be on the location bar. browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK, true, -1, false, NULL); - EXPECT_EQ(browser_view->GetLocationBarView(), - focus_manager->GetFocusedView()); + CheckViewHasFocus(VIEW_ID_LOCATION_BAR); } +#if defined(OS_WIN) // Tests that focus goes where expected when using reload. IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { HTTPTestServer* server = StartHTTPServer(); @@ -689,3 +726,4 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReloadCrashedTab) { EXPECT_EQ(browser_view->GetTabContentsContainerView(), focus_manager->GetFocusedView()); } +#endif // defined(OS_WIN) diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 5ebd804..ed181af 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -3572,6 +3572,131 @@ ], }, { + 'target_name': 'interactive_ui_tests', + 'type': 'executable', + 'msvs_guid': '018D4F38-6272-448F-A864-976DA09F05D0', + 'dependencies': [ + 'chrome', + 'chrome_resources', + 'chrome_strings', + 'debugger', + 'test_support_common', + 'test_support_ui', + 'third_party/hunspell/hunspell.gyp:hunspell', + '../net/net.gyp:net_resources', + '../skia/skia.gyp:skia', + '../third_party/icu38/icu38.gyp:icui18n', + '../third_party/libpng/libpng.gyp:libpng', + '../third_party/libxml/libxml.gyp:libxml', + '../third_party/zlib/zlib.gyp:zlib', + '../testing/gtest.gyp:gtest', + '../third_party/npapi/npapi.gyp:npapi', + # run time dependency + '../webkit/tools/test_shell/test_shell.gyp:npapi_test_plugin', + '../webkit/webkit.gyp:webkit_resources', + ], + 'include_dirs': [ + '..', + ], + 'sources': [ + 'browser/browser_focus_uitest.cc', + 'browser/debugger/devtools_sanity_unittest.cc', + 'browser/views/bookmark_bar_view_test.cc', + 'browser/blocked_popup_container_interactive_uitest.cc', + 'browser/views/find_bar_win_interactive_uitest.cc', + 'browser/views/tabs/tab_dragging_test.cc', + 'test/interactive_ui/npapi_interactive_test.cc', + 'test/interactive_ui/view_event_test_base.cc', + 'test/interactive_ui/view_event_test_base.h', + ], + 'conditions': [ + ['OS=="linux"', { + 'dependencies': [ + '../build/linux/system.gyp:gtk', + ], + 'sources!': [ + # TODO(port) + 'browser/debugger/devtools_sanity_unittest.cc', + 'browser/views/bookmark_bar_view_test.cc', + 'browser/blocked_popup_container_interactive_uitest.cc', + 'browser/views/find_bar_win_interactive_uitest.cc', + 'browser/views/tabs/tab_dragging_test.cc', + 'test/interactive_ui/npapi_interactive_test.cc', + 'test/interactive_ui/view_event_test_base.cc', + 'test/interactive_ui/view_event_test_base.h', + ], + }], + ['OS=="linux" and toolkit_views==1', { + 'dependencies': [ + '../views/views.gyp:views', + ], + }], + ['OS=="mac"', { + 'sources!': [ + # TODO(port) + 'browser/browser_focus_uitest.cc', + 'browser/debugger/devtools_sanity_unittest.cc', + 'browser/views/bookmark_bar_view_test.cc', + 'browser/blocked_popup_container_interactive_uitest.cc', + 'browser/views/find_bar_win_interactive_uitest.cc', + 'browser/views/tabs/tab_dragging_test.cc', + 'test/interactive_ui/npapi_interactive_test.cc', + 'test/interactive_ui/view_event_test_base.cc', + 'test/interactive_ui/view_event_test_base.h', + ], + }], + ['OS=="win"', { + 'include_dirs': [ + 'third_party/wtl/include', + ], + 'dependencies': [ + 'chrome_dll_version', + 'crash_service', # run time dependency + 'installer/installer.gyp:installer_util_strings', + '../views/views.gyp:views', + ], + 'sources': [ + '../webkit/glue/resources/aliasb.cur', + '../webkit/glue/resources/cell.cur', + '../webkit/glue/resources/col_resize.cur', + '../webkit/glue/resources/copy.cur', + '../webkit/glue/resources/row_resize.cur', + '../webkit/glue/resources/vertical_text.cur', + '../webkit/glue/resources/zoom_in.cur', + '../webkit/glue/resources/zoom_out.cur', + + 'app/chrome_dll.rc', + 'test/data/resource.rc', + + # TODO: It would be nice to have these pulled in + # automatically from direct_dependent_settings in + # their various targets (net.gyp:net_resources, etc.), + # but that causes errors in other targets when + # resulting .res files get referenced multiple times. + '<(SHARED_INTERMEDIATE_DIR)/chrome/browser_resources.rc', + '<(SHARED_INTERMEDIATE_DIR)/chrome/common_resources.rc', + '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources.rc', + '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc', + '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.rc', + + 'tools/build/win/precompiled_wtl.h', + 'tools/build/win/precompiled_wtl.cc', + ], + 'configurations': { + 'Debug': { + 'msvs_precompiled_header': 'tools/build/win/precompiled_wtl.h', + 'msvs_precompiled_source': 'tools/build/win/precompiled_wtl.cc', + 'msvs_settings': { + 'VCLinkerTool': { + 'LinkIncremental': '<(msvs_large_module_debug_link_mode)', + }, + }, + }, + }, + }], + ], + }, + { 'target_name': 'ui_tests', 'type': 'executable', 'msvs_guid': '76235B67-1C27-4627-8A33-4B2E1EF93EDE', @@ -5227,89 +5352,6 @@ ], }, { - 'target_name': 'interactive_ui_tests', - 'type': 'executable', - 'msvs_guid': '018D4F38-6272-448F-A864-976DA09F05D0', - 'dependencies': [ - 'chrome', - 'chrome_dll_version', - 'chrome_resources', - 'chrome_strings', - 'crash_service', # run time dependency - 'debugger', - 'installer/installer.gyp:installer_util_strings', - 'test_support_common', - 'test_support_ui', - 'third_party/hunspell/hunspell.gyp:hunspell', - '../net/net.gyp:net_resources', - '../skia/skia.gyp:skia', - '../third_party/icu38/icu38.gyp:icui18n', - '../third_party/libpng/libpng.gyp:libpng', - '../third_party/libxml/libxml.gyp:libxml', - '../third_party/zlib/zlib.gyp:zlib', - '../testing/gtest.gyp:gtest', - '../third_party/npapi/npapi.gyp:npapi', - '../views/views.gyp:views', - # run time dependency - '../webkit/tools/test_shell/test_shell.gyp:npapi_test_plugin', - '../webkit/webkit.gyp:webkit_resources', - ], - 'include_dirs': [ - '..', - 'third_party/wtl/include', - ], - 'sources': [ - 'browser/browser_focus_uitest.cc', - 'browser/debugger/devtools_sanity_unittest.cc', - 'browser/views/bookmark_bar_view_test.cc', - 'browser/blocked_popup_container_interactive_uitest.cc', - 'browser/views/find_bar_win_interactive_uitest.cc', - 'browser/views/tabs/tab_dragging_test.cc', - 'test/interactive_ui/npapi_interactive_test.cc', - 'test/interactive_ui/view_event_test_base.cc', - 'test/interactive_ui/view_event_test_base.h', - - # Windows-only below here, will need addressing if/when - # this gets ported. - '../webkit/glue/resources/aliasb.cur', - '../webkit/glue/resources/cell.cur', - '../webkit/glue/resources/col_resize.cur', - '../webkit/glue/resources/copy.cur', - '../webkit/glue/resources/row_resize.cur', - '../webkit/glue/resources/vertical_text.cur', - '../webkit/glue/resources/zoom_in.cur', - '../webkit/glue/resources/zoom_out.cur', - - 'app/chrome_dll.rc', - 'test/data/resource.rc', - - # TODO: It would be nice to have these pulled in - # automatically from direct_dependent_settings in - # their various targets (net.gyp:net_resources, etc.), - # but that causes errors in other targets when - # resulting .res files get referenced multiple times. - '<(SHARED_INTERMEDIATE_DIR)/chrome/browser_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/chrome/common_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.rc', - - 'tools/build/win/precompiled_wtl.h', - 'tools/build/win/precompiled_wtl.cc', - ], - 'configurations': { - 'Debug': { - 'msvs_precompiled_header': 'tools/build/win/precompiled_wtl.h', - 'msvs_precompiled_source': 'tools/build/win/precompiled_wtl.cc', - 'msvs_settings': { - 'VCLinkerTool': { - 'LinkIncremental': '<(msvs_large_module_debug_link_mode)', - }, - }, - }, - }, - }, - { 'target_name': 'plugin_tests', 'type': 'executable', 'msvs_guid': 'A1CAA831-C507-4B2E-87F3-AEC63C9907F9', |