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

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_test.cc

Issue 2685333005: ash: fix regression where ctrl+n put new window on wrong desktop (Closed)
Patch Set: We have both kinds of compile fixes: mac and windows Created 3 years, 10 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
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 <limits.h> 5 #include <limits.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // browser test doesn't seem to do anything, so can't test the opposite 166 // browser test doesn't seem to do anything, so can't test the opposite
167 // either. 167 // either.
168 EXPECT_EQ(browser()->window()->IsActive(), 168 EXPECT_EQ(browser()->window()->IsActive(),
169 api_test_utils::GetBoolean(result.get(), "focused")); 169 api_test_utils::GetBoolean(result.get(), "focused"));
170 170
171 // TODO(aa): Minimized and maximized dimensions. Is there a way to set 171 // TODO(aa): Minimized and maximized dimensions. Is there a way to set
172 // minimize/maximize programmatically? 172 // minimize/maximize programmatically?
173 173
174 // Popup. 174 // Popup.
175 Browser* popup_browser = new Browser( 175 Browser* popup_browser = new Browser(
176 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); 176 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), true));
177 function = new WindowsGetFunction(); 177 function = new WindowsGetFunction();
178 function->set_extension(extension.get()); 178 function->set_extension(extension.get());
179 result.reset(utils::ToDictionary( 179 result.reset(utils::ToDictionary(
180 utils::RunFunctionAndReturnSingleResult( 180 utils::RunFunctionAndReturnSingleResult(
181 function.get(), 181 function.get(),
182 base::StringPrintf( 182 base::StringPrintf(
183 "[%u]", ExtensionTabUtil::GetWindowId(popup_browser)), 183 "[%u]", ExtensionTabUtil::GetWindowId(popup_browser)),
184 browser()))); 184 browser())));
185 EXPECT_EQ("popup", api_test_utils::GetString(result.get(), "type")); 185 EXPECT_EQ("popup", api_test_utils::GetString(result.get(), "type"));
186 186
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 EXPECT_EQ(window_ids, result_ids); 637 EXPECT_EQ(window_ids, result_ids);
638 638
639 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); 639 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools);
640 } 640 }
641 641
642 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) { 642 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) {
643 // Test creates new popup window, closes it right away and then tries to open 643 // Test creates new popup window, closes it right away and then tries to open
644 // a new tab in it. Tab should not be opened in the popup window, but in a 644 // a new tab in it. Tab should not be opened in the popup window, but in a
645 // tabbed browser window. 645 // tabbed browser window.
646 Browser* popup_browser = new Browser( 646 Browser* popup_browser = new Browser(
647 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); 647 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), true));
648 int window_id = ExtensionTabUtil::GetWindowId(popup_browser); 648 int window_id = ExtensionTabUtil::GetWindowId(popup_browser);
649 chrome::CloseWindow(popup_browser); 649 chrome::CloseWindow(popup_browser);
650 650
651 scoped_refptr<TabsCreateFunction> create_tab_function( 651 scoped_refptr<TabsCreateFunction> create_tab_function(
652 new TabsCreateFunction()); 652 new TabsCreateFunction());
653 create_tab_function->set_extension(test_util::CreateEmptyExtension().get()); 653 create_tab_function->set_extension(test_util::CreateEmptyExtension().get());
654 // Without a callback the function will not generate a result. 654 // Without a callback the function will not generate a result.
655 create_tab_function->set_has_callback(true); 655 create_tab_function->set_has_callback(true);
656 656
657 static const char kNewBlankTabArgs[] = 657 static const char kNewBlankTabArgs[] =
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 EXPECT_NE(nullptr, widget); 861 EXPECT_NE(nullptr, widget);
862 WidgetActivatedWaiter waiter(widget); 862 WidgetActivatedWaiter waiter(widget);
863 waiter.ActivateAndWait(); 863 waiter.ActivateAndWait();
864 } 864 }
865 865
866 Browser* ExtensionWindowLastFocusedTest::CreateBrowserWithEmptyTab( 866 Browser* ExtensionWindowLastFocusedTest::CreateBrowserWithEmptyTab(
867 bool as_popup) { 867 bool as_popup) {
868 Browser* new_browser; 868 Browser* new_browser;
869 if (as_popup) 869 if (as_popup)
870 new_browser = new Browser( 870 new_browser = new Browser(
871 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); 871 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), true));
872 else 872 else
873 new_browser = new Browser(Browser::CreateParams(browser()->profile())); 873 new_browser =
874 new Browser(Browser::CreateParams(browser()->profile(), true));
874 AddBlankTabAndShow(new_browser); 875 AddBlankTabAndShow(new_browser);
875 return new_browser; 876 return new_browser;
876 } 877 }
877 878
878 int ExtensionWindowLastFocusedTest::GetTabId( 879 int ExtensionWindowLastFocusedTest::GetTabId(
879 const base::DictionaryValue* value) const { 880 const base::DictionaryValue* value) const {
880 const base::ListValue* tabs = NULL; 881 const base::ListValue* tabs = NULL;
881 if (!value->GetList(keys::kTabsKey, &tabs)) 882 if (!value->GetList(keys::kTabsKey, &tabs))
882 return -2; 883 return -2;
883 const base::Value* tab = NULL; 884 const base::Value* tab = NULL;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 LoadExtension(test_data_dir_.AppendASCII("api_test/windows/events"))); 1249 LoadExtension(test_data_dir_.AppendASCII("api_test/windows/events")));
1249 ASSERT_TRUE(listener.WaitUntilSatisfied()); 1250 ASSERT_TRUE(listener.WaitUntilSatisfied());
1250 1251
1251 AppWindow* app_window = CreateTestAppWindow( 1252 AppWindow* app_window = CreateTestAppWindow(
1252 "{\"outerBounds\": " 1253 "{\"outerBounds\": "
1253 "{\"width\": 300, \"height\": 300," 1254 "{\"width\": 300, \"height\": 300,"
1254 " \"minWidth\": 200, \"minHeight\": 200," 1255 " \"minWidth\": 200, \"minHeight\": 200,"
1255 " \"maxWidth\": 400, \"maxHeight\": 400}}"); 1256 " \"maxWidth\": 400, \"maxHeight\": 400}}");
1256 1257
1257 Browser* browser_window = 1258 Browser* browser_window =
1258 new Browser(Browser::CreateParams(browser()->profile())); 1259 new Browser(Browser::CreateParams(browser()->profile(), true));
1259 AddBlankTabAndShow(browser_window); 1260 AddBlankTabAndShow(browser_window);
1260 1261
1261 DevToolsWindow* devtools_window = 1262 DevToolsWindow* devtools_window =
1262 DevToolsWindowTesting::OpenDevToolsWindowSync( 1263 DevToolsWindowTesting::OpenDevToolsWindowSync(
1263 browser()->tab_strip_model()->GetWebContentsAt(0), 1264 browser()->tab_strip_model()->GetWebContentsAt(0),
1264 false /* is_docked */); 1265 false /* is_docked */);
1265 1266
1266 chrome::CloseWindow(browser_window); 1267 chrome::CloseWindow(browser_window);
1267 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); 1268 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window);
1268 CloseAppWindow(app_window); 1269 CloseAppWindow(app_window);
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 EXPECT_EQ(first_web_contents, 2131 EXPECT_EQ(first_web_contents,
2131 browser()->tab_strip_model()->GetActiveWebContents()); 2132 browser()->tab_strip_model()->GetActiveWebContents());
2132 browser()->tab_strip_model()->ActivateTabAt(1, true); 2133 browser()->tab_strip_model()->ActivateTabAt(1, true);
2133 EXPECT_EQ(second_web_contents, 2134 EXPECT_EQ(second_web_contents,
2134 browser()->tab_strip_model()->GetActiveWebContents()); 2135 browser()->tab_strip_model()->GetActiveWebContents());
2135 2136
2136 EXPECT_EQ(url, second_web_contents->GetVisibleURL()); 2137 EXPECT_EQ(url, second_web_contents->GetVisibleURL());
2137 } 2138 }
2138 2139
2139 } // namespace extensions 2140 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698