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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_interactive_test.cc

Issue 2419763002: Enable ExtensionTabsTest.QueryLastFocusedWindowTabs test (Closed)
Patch Set: disable the test on Mac only Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/tabs/tabs_interactive_test.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc b/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc
index 879acfef8deb27f36afc7027309d4be2237b7ae1..c04fac7aff3dcf0f88c3c2d4ae1379a5602a3f1b 100644
--- a/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc
@@ -14,10 +14,10 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "extensions/browser/api_test_utils.h"
#include "extensions/common/test_util.h"
+#include "ui/views/test/widget_test.h"
namespace api_test_utils = extensions::api_test_utils;
namespace keys = extensions::tabs_constants;
@@ -69,32 +69,36 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_GetLastFocusedWindow) {
EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs));
}
-// Flaky: http://crbug.com/136562
-IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
+// Activating a browser window and waiting for the activation to happen requires
+// views::Widget which is not available on MACOSX. Deactivate for now.
+#if defined(OS_MACOSX)
+#define MAYBE_QueryLastFocusedWindowTabs DISABLED_QueryLastFocusedWindowTabs
+#else
+#define MAYBE_QueryLastFocusedWindowTabs QueryLastFocusedWindowTabs
+#endif
+IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_QueryLastFocusedWindowTabs) {
const size_t kExtraWindows = 2;
for (size_t i = 0; i < kExtraWindows; ++i)
CreateBrowser(browser()->profile());
- Browser* focused_window = CreateBrowser(browser()->profile());
-#if defined(OS_MACOSX)
- // See BrowserWindowCocoa::Show. In tests, Browser::window()->IsActive won't
- // work unless we fake the browser being launched by the user.
- ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
- focused_window->window()->GetNativeWindow()));
-#endif
-
- // Needed on Mac and Linux so that the BrowserWindow::IsActive calls work.
- content::RunAllPendingInMessageLoop();
+ Browser* focused_browser = CreateBrowser(browser()->profile());
+ gfx::NativeWindow window = focused_browser->window()->GetNativeWindow();
+ views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
+ views::test::WidgetActivationWaiter waiter(widget, true);
+ waiter.Wait();
- GURL url;
- AddTabAtIndexToBrowser(focused_window, 0, url, ui::PAGE_TRANSITION_LINK,
+ GURL url("chrome://settings");
asargent_no_longer_on_chrome 2016/10/17 20:33:14 Out of curiosity, any particular reason you used c
Qiang(Joe) Xu 2016/10/21 22:29:22 Done.
+ AddTabAtIndexToBrowser(focused_browser, 0, url, ui::PAGE_TRANSITION_LINK,
true);
int focused_window_id =
- extensions::ExtensionTabUtil::GetWindowId(focused_window);
+ extensions::ExtensionTabUtil::GetWindowId(focused_browser);
// Get tabs in the 'last focused' window called from non-focused browser.
scoped_refptr<extensions::TabsQueryFunction> function =
new extensions::TabsQueryFunction();
+ scoped_refptr<extensions::Extension> extension(
+ extensions::test_util::CreateEmptyExtension());
+ function->set_extension(extension.get());
std::unique_ptr<base::ListValue> result(
utils::ToList(utils::RunFunctionAndReturnSingleResult(
function.get(), "[{\"lastFocusedWindow\":true}]", browser())));
@@ -111,6 +115,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
// Get tabs NOT in the 'last focused' window called from the focused browser.
function = new extensions::TabsQueryFunction();
+ function->set_extension(extension.get());
result.reset(utils::ToList(
utils::RunFunctionAndReturnSingleResult(function.get(),
"[{\"lastFocusedWindow\":false}]",
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698