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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 9 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
11 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "chrome/browser/extensions/extension_function_test_utils.h" 12 #include "chrome/browser/extensions/extension_function_test_utils.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 13 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/interactive_test_utils.h"
18 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
19 #include "extensions/browser/api_test_utils.h" 18 #include "extensions/browser/api_test_utils.h"
20 #include "extensions/common/test_util.h" 19 #include "extensions/common/test_util.h"
20 #include "ui/views/test/widget_test.h"
21 21
22 namespace api_test_utils = extensions::api_test_utils; 22 namespace api_test_utils = extensions::api_test_utils;
23 namespace keys = extensions::tabs_constants; 23 namespace keys = extensions::tabs_constants;
24 namespace utils = extension_function_test_utils; 24 namespace utils = extension_function_test_utils;
25 25
26 typedef InProcessBrowserTest ExtensionTabsTest; 26 typedef InProcessBrowserTest ExtensionTabsTest;
27 27
28 // http://crbug.com/154081 for Aura specific 28 // http://crbug.com/154081 for Aura specific
29 // http://crbug.com/179063 for other general failures on try bots. 29 // http://crbug.com/179063 for other general failures on try bots.
30 #if defined(OS_WIN) 30 #if defined(OS_WIN)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 "[{\"populate\": true}]", 62 "[{\"populate\": true}]",
63 browser()))); 63 browser())));
64 64
65 // The id should always match the last focused window and does not depend 65 // The id should always match the last focused window and does not depend
66 // on what was passed to RunFunctionAndReturnSingleResult. 66 // on what was passed to RunFunctionAndReturnSingleResult.
67 EXPECT_EQ(focused_window_id, api_test_utils::GetInteger(result.get(), "id")); 67 EXPECT_EQ(focused_window_id, api_test_utils::GetInteger(result.get(), "id"));
68 // "populate" was enabled so tabs should be populated. 68 // "populate" was enabled so tabs should be populated.
69 EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); 69 EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs));
70 } 70 }
71 71
72 // Flaky: http://crbug.com/136562 72 // Activating a browser window and waiting for the activation to happen requires
73 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) { 73 // views::Widget which is not available on MACOSX. Deactivate for now.
74 #if defined(OS_MACOSX)
75 #define MAYBE_QueryLastFocusedWindowTabs DISABLED_QueryLastFocusedWindowTabs
76 #else
77 #define MAYBE_QueryLastFocusedWindowTabs QueryLastFocusedWindowTabs
78 #endif
79 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_QueryLastFocusedWindowTabs) {
74 const size_t kExtraWindows = 2; 80 const size_t kExtraWindows = 2;
75 for (size_t i = 0; i < kExtraWindows; ++i) 81 for (size_t i = 0; i < kExtraWindows; ++i)
76 CreateBrowser(browser()->profile()); 82 CreateBrowser(browser()->profile());
77 83
78 Browser* focused_window = CreateBrowser(browser()->profile()); 84 Browser* focused_browser = CreateBrowser(browser()->profile());
79 #if defined(OS_MACOSX) 85 gfx::NativeWindow window = focused_browser->window()->GetNativeWindow();
80 // See BrowserWindowCocoa::Show. In tests, Browser::window()->IsActive won't 86 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
81 // work unless we fake the browser being launched by the user. 87 views::test::WidgetActivationWaiter waiter(widget, true);
82 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( 88 waiter.Wait();
83 focused_window->window()->GetNativeWindow()));
84 #endif
85 89
86 // Needed on Mac and Linux so that the BrowserWindow::IsActive calls work. 90 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.
87 content::RunAllPendingInMessageLoop(); 91 AddTabAtIndexToBrowser(focused_browser, 0, url, ui::PAGE_TRANSITION_LINK,
88
89 GURL url;
90 AddTabAtIndexToBrowser(focused_window, 0, url, ui::PAGE_TRANSITION_LINK,
91 true); 92 true);
92 int focused_window_id = 93 int focused_window_id =
93 extensions::ExtensionTabUtil::GetWindowId(focused_window); 94 extensions::ExtensionTabUtil::GetWindowId(focused_browser);
94 95
95 // Get tabs in the 'last focused' window called from non-focused browser. 96 // Get tabs in the 'last focused' window called from non-focused browser.
96 scoped_refptr<extensions::TabsQueryFunction> function = 97 scoped_refptr<extensions::TabsQueryFunction> function =
97 new extensions::TabsQueryFunction(); 98 new extensions::TabsQueryFunction();
99 scoped_refptr<extensions::Extension> extension(
100 extensions::test_util::CreateEmptyExtension());
101 function->set_extension(extension.get());
98 std::unique_ptr<base::ListValue> result( 102 std::unique_ptr<base::ListValue> result(
99 utils::ToList(utils::RunFunctionAndReturnSingleResult( 103 utils::ToList(utils::RunFunctionAndReturnSingleResult(
100 function.get(), "[{\"lastFocusedWindow\":true}]", browser()))); 104 function.get(), "[{\"lastFocusedWindow\":true}]", browser())));
101 105
102 base::ListValue* result_tabs = result.get(); 106 base::ListValue* result_tabs = result.get();
103 // We should have one initial tab and one added tab. 107 // We should have one initial tab and one added tab.
104 EXPECT_EQ(2u, result_tabs->GetSize()); 108 EXPECT_EQ(2u, result_tabs->GetSize());
105 for (size_t i = 0; i < result_tabs->GetSize(); ++i) { 109 for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
106 base::DictionaryValue* result_tab = NULL; 110 base::DictionaryValue* result_tab = NULL;
107 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); 111 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
108 EXPECT_EQ(focused_window_id, 112 EXPECT_EQ(focused_window_id,
109 api_test_utils::GetInteger(result_tab, keys::kWindowIdKey)); 113 api_test_utils::GetInteger(result_tab, keys::kWindowIdKey));
110 } 114 }
111 115
112 // Get tabs NOT in the 'last focused' window called from the focused browser. 116 // Get tabs NOT in the 'last focused' window called from the focused browser.
113 function = new extensions::TabsQueryFunction(); 117 function = new extensions::TabsQueryFunction();
118 function->set_extension(extension.get());
114 result.reset(utils::ToList( 119 result.reset(utils::ToList(
115 utils::RunFunctionAndReturnSingleResult(function.get(), 120 utils::RunFunctionAndReturnSingleResult(function.get(),
116 "[{\"lastFocusedWindow\":false}]", 121 "[{\"lastFocusedWindow\":false}]",
117 browser()))); 122 browser())));
118 123
119 result_tabs = result.get(); 124 result_tabs = result.get();
120 // We should get one tab for each extra window and one for the initial window. 125 // We should get one tab for each extra window and one for the initial window.
121 EXPECT_EQ(kExtraWindows + 1, result_tabs->GetSize()); 126 EXPECT_EQ(kExtraWindows + 1, result_tabs->GetSize());
122 for (size_t i = 0; i < result_tabs->GetSize(); ++i) { 127 for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
123 base::DictionaryValue* result_tab = NULL; 128 base::DictionaryValue* result_tab = NULL;
124 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); 129 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
125 EXPECT_NE(focused_window_id, 130 EXPECT_NE(focused_window_id,
126 api_test_utils::GetInteger(result_tab, keys::kWindowIdKey)); 131 api_test_utils::GetInteger(result_tab, keys::kWindowIdKey));
127 } 132 }
128 } 133 }
129 134
130 #if defined(OS_WIN) // http://crbug.com/154081 && http://crbug.com/171080 135 #if defined(OS_WIN) // http://crbug.com/154081 && http://crbug.com/171080
131 #define MAYBE_TabCurrentWindow DISABLED_TabCurrentWindow 136 #define MAYBE_TabCurrentWindow DISABLED_TabCurrentWindow
132 #else 137 #else
133 #define MAYBE_TabCurrentWindow TabCurrentWindow 138 #define MAYBE_TabCurrentWindow TabCurrentWindow
134 #endif 139 #endif
135 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabCurrentWindow) { 140 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabCurrentWindow) {
136 ASSERT_TRUE(RunExtensionTest("tabs/current_window")) << message_; 141 ASSERT_TRUE(RunExtensionTest("tabs/current_window")) << message_;
137 } 142 }
OLDNEW
« 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