diff options
-rw-r--r-- | chrome/browser/extensions/api/tabs/tabs_interactive_test.cc | 53 | ||||
-rw-r--r-- | chrome/browser/extensions/api/tabs/tabs_test.cc | 35 | ||||
-rw-r--r-- | chrome/browser/extensions/window_open_apitest.cc | 7 | ||||
-rw-r--r-- | chrome/browser/extensions/window_open_interactive_apitest.cc | 21 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 8 |
5 files changed, 81 insertions, 43 deletions
diff --git a/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc b/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc new file mode 100644 index 0000000..7114cbc --- /dev/null +++ b/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc @@ -0,0 +1,53 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/extensions/api/tabs/tabs.h" + +#include "base/values.h" +#include "chrome/browser/extensions/api/tabs/tabs_constants.h" +#include "chrome/browser/extensions/extension_function_test_utils.h" +#include "chrome/browser/extensions/extension_tab_util.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/ui_test_utils.h" + +namespace keys = extensions::tabs_constants; +namespace utils = extension_function_test_utils; + +typedef InProcessBrowserTest ExtensionTabsTest; + +IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetLastFocusedWindow) { + // Create a new window which making it the "last focused" window. + // Note that "last focused" means the "top" most window. + Browser* new_browser = CreateBrowser(browser()->profile()); + int focused_window_id = ExtensionTabUtil::GetWindowId(new_browser); + + scoped_refptr<GetLastFocusedWindowFunction> function = + new GetLastFocusedWindowFunction(); + scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); + function->set_extension(extension.get()); + scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( + utils::RunFunctionAndReturnSingleResult(function.get(), + "[]", + new_browser))); + + // The id should always match the last focused window and does not depend + // on what was passed to RunFunctionAndReturnSingleResult. + EXPECT_EQ(focused_window_id, utils::GetInteger(result.get(), "id")); + ListValue* tabs = NULL; + EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); + + function = new GetLastFocusedWindowFunction(); + function->set_extension(extension.get()); + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnSingleResult(function.get(), + "[{\"populate\": true}]", + browser()))); + + // The id should always match the last focused window and does not depend + // on what was passed to RunFunctionAndReturnSingleResult. + EXPECT_EQ(focused_window_id, utils::GetInteger(result.get(), "id")); + // "populate" was enabled so tabs should be populated. + EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); +} diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc index e9c97488..49ba37c 100644 --- a/chrome/browser/extensions/api/tabs/tabs_test.cc +++ b/chrome/browser/extensions/api/tabs/tabs_test.cc @@ -179,41 +179,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); } -IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetLastFocusedWindow) { - // Create a new window which making it the "last focused" window. - // Note that "last focused" means the "top" most window. - Browser* new_browser = CreateBrowser(browser()->profile()); - int focused_window_id = ExtensionTabUtil::GetWindowId(new_browser); - - scoped_refptr<GetLastFocusedWindowFunction> function = - new GetLastFocusedWindowFunction(); - scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); - function->set_extension(extension.get()); - scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnSingleResult(function.get(), - "[]", - new_browser))); - - // The id should always match the last focused window and does not depend - // on what was passed to RunFunctionAndReturnSingleResult. - EXPECT_EQ(focused_window_id, utils::GetInteger(result.get(), "id")); - ListValue* tabs = NULL; - EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); - - function = new GetLastFocusedWindowFunction(); - function->set_extension(extension.get()); - result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnSingleResult(function.get(), - "[{\"populate\": true}]", - browser()))); - - // The id should always match the last focused window and does not depend - // on what was passed to RunFunctionAndReturnSingleResult. - EXPECT_EQ(focused_window_id, utils::GetInteger(result.get(), "id")); - // "populate" was enabled so tabs should be populated. - EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); -} - IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { const size_t NUM_WINDOWS = 5; std::set<int> window_ids; diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc index 6f2fd2e..43de0f7 100644 --- a/chrome/browser/extensions/window_open_apitest.cc +++ b/chrome/browser/extensions/window_open_apitest.cc @@ -227,13 +227,6 @@ IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanelDetached) { ASSERT_TRUE(RunExtensionTest("window_open/panel_detached")) << message_; } -#if defined(OS_MACOSX) || defined(OS_WIN) -// Focus test fails if there is no window manager on Linux. -IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, WindowOpenFocus) { - ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_; -} -#endif - IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, CloseNonExtensionPanelsOnUninstall) { #if defined(USE_ASH) diff --git a/chrome/browser/extensions/window_open_interactive_apitest.cc b/chrome/browser/extensions/window_open_interactive_apitest.cc new file mode 100644 index 0000000..1377d15 --- /dev/null +++ b/chrome/browser/extensions/window_open_interactive_apitest.cc @@ -0,0 +1,21 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/common/chrome_switches.h" + +class WindowOpenPanelTest : public ExtensionApiTest { + virtual void SetUpCommandLine(CommandLine* command_line) { + ExtensionApiTest::SetUpCommandLine(command_line); + command_line->AppendSwitch(switches::kEnablePanels); + } +}; + +#if defined(OS_MACOSX) || defined(OS_WIN) +// Focus test fails if there is no window manager on Linux. +IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, WindowOpenFocus) { + ASSERT_TRUE(RunExtensionTest("window_open/focus")) << message_; +} +#endif diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 528e40c0..a9738a4 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -139,6 +139,7 @@ 'chrome', 'chrome_resources.gyp:chrome_resources', 'chrome_resources.gyp:chrome_strings', + 'common/extensions/api/api.gyp:api', 'debugger', 'test_support_common', # NOTE: don't add test_support_ui, no more UITests. See @@ -167,6 +168,12 @@ ], 'sources': [ 'browser/browser_keyevents_browsertest.cc', + 'browser/extensions/api/tabs/tabs_interactive_test.cc', + 'browser/extensions/extension_apitest.cc', + 'browser/extensions/extension_browsertest.cc', + 'browser/extensions/extension_function_test_utils.cc', + 'browser/extensions/extension_keybinding_apitest.cc', + 'browser/extensions/window_open_interactive_apitest.cc', 'browser/instant/instant_browsertest.cc', 'browser/mouseleave_browsertest.cc', 'browser/printing/print_dialog_cloud_interative_uitest.cc', @@ -924,7 +931,6 @@ 'browser/extensions/extension_incognito_apitest.cc', 'browser/extensions/extension_install_ui_browsertest.cc', 'browser/extensions/extension_javascript_url_apitest.cc', - 'browser/extensions/extension_keybinding_apitest.cc', 'browser/extensions/extension_messages_apitest.cc', 'browser/extensions/extension_override_apitest.cc', 'browser/extensions/extension_resource_request_policy_apitest.cc', |