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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 2772713002: Remove IDC_CREATE_SHORTCUT and its associated UI. (Closed)
Patch Set: rebase to get r462081 Created 3 years, 8 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 content::RenderProcessHost::iterator it( 1212 content::RenderProcessHost::iterator it(
1213 content::RenderProcessHost::AllHostsIterator()); 1213 content::RenderProcessHost::AllHostsIterator());
1214 for (; !it.IsAtEnd(); it.Advance()) { 1214 for (; !it.IsAtEnd(); it.Advance()) {
1215 base::TimeDelta renderer_td = 1215 base::TimeDelta renderer_td =
1216 it.GetCurrentValue()->GetChildProcessIdleTime(); 1216 it.GetCurrentValue()->GetChildProcessIdleTime();
1217 base::TimeDelta browser_td = base::TimeTicks::Now() - start; 1217 base::TimeDelta browser_td = base::TimeTicks::Now() - start;
1218 EXPECT_TRUE(browser_td >= renderer_td); 1218 EXPECT_TRUE(browser_td >= renderer_td);
1219 } 1219 }
1220 } 1220 }
1221 1221
1222 // Test IDC_CREATE_SHORTCUTS command is enabled for url scheme file, ftp, http
1223 // and https and disabled for chrome://, about:// etc.
1224 // TODO(pinkerton): Disable app-mode in the model until we implement it
1225 // on the Mac. http://crbug.com/13148
1226 #if !defined(OS_MACOSX)
1227 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutFile) {
1228 CommandUpdater* command_updater =
1229 browser()->command_controller()->command_updater();
1230
1231 static const base::FilePath::CharType* kEmptyFile =
1232 FILE_PATH_LITERAL("empty.html");
1233 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath(
1234 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile)));
1235 ASSERT_TRUE(file_url.SchemeIs(url::kFileScheme));
1236 ui_test_utils::NavigateToURL(browser(), file_url);
1237 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1238 }
1239
1240 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttp) {
1241 CommandUpdater* command_updater =
1242 browser()->command_controller()->command_updater();
1243
1244 ASSERT_TRUE(embedded_test_server()->Start());
1245 GURL http_url(embedded_test_server()->GetURL("/"));
1246 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme));
1247 ui_test_utils::NavigateToURL(browser(), http_url);
1248 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1249 }
1250
1251 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttps) {
1252 CommandUpdater* command_updater =
1253 browser()->command_controller()->command_updater();
1254
1255 net::EmbeddedTestServer https_test_server(
1256 net::EmbeddedTestServer::TYPE_HTTPS);
1257 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot));
1258 ASSERT_TRUE(https_test_server.Start());
1259
1260 GURL https_url(https_test_server.GetURL("/"));
1261 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme));
1262 ui_test_utils::NavigateToURL(browser(), https_url);
1263 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1264 }
1265
1266 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutFtp) {
1267 CommandUpdater* command_updater =
1268 browser()->command_controller()->command_updater();
1269
1270 net::SpawnedTestServer test_server(net::SpawnedTestServer::TYPE_FTP,
1271 net::SpawnedTestServer::kLocalhost,
1272 base::FilePath(kDocRoot));
1273 ASSERT_TRUE(test_server.Start());
1274 GURL ftp_url(test_server.GetURL(std::string()));
1275 ASSERT_TRUE(ftp_url.SchemeIs(url::kFtpScheme));
1276 ui_test_utils::NavigateToURL(browser(), ftp_url);
1277 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1278 }
1279
1280 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) {
1281 CommandUpdater* command_updater =
1282 browser()->command_controller()->command_updater();
1283
1284 // Urls that should not have shortcuts.
1285 GURL new_tab_url(chrome::kChromeUINewTabURL);
1286 ui_test_utils::NavigateToURL(browser(), new_tab_url);
1287 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1288
1289 GURL history_url(chrome::kChromeUIHistoryURL);
1290 ui_test_utils::NavigateToURL(browser(), history_url);
1291 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1292
1293 GURL blank_url(url::kAboutBlankURL);
1294 ui_test_utils::NavigateToURL(browser(), blank_url);
1295 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1296 }
1297
1298 // Change a tab into an application window.
1299 // DISABLED: http://crbug.com/72310
1300 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) {
1301 ASSERT_TRUE(embedded_test_server()->Start());
1302 GURL http_url(embedded_test_server()->GetURL("/"));
1303 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme));
1304
1305 ASSERT_EQ(1, browser()->tab_strip_model()->count());
1306 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0);
1307 WebContents* app_tab = chrome::AddSelectedTabWithURL(
1308 browser(), http_url, ui::PAGE_TRANSITION_TYPED);
1309 ASSERT_EQ(2, browser()->tab_strip_model()->count());
1310 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
1311
1312 // Normal tabs should accept load drops.
1313 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops);
1314 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops);
1315
1316 // Turn |app_tab| into a tab in an app panel.
1317 chrome::ConvertTabToAppWindow(browser(), app_tab);
1318
1319 // The launch should have created a new browser.
1320 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile()));
1321
1322 // Find the new browser.
1323 Browser* app_browser = NULL;
1324 for (auto* b : *BrowserList::GetInstance()) {
1325 if (b != browser())
1326 app_browser = b;
1327 }
1328 ASSERT_TRUE(app_browser);
1329
1330 // Check that the tab contents is in the new browser, and not in the old.
1331 ASSERT_EQ(1, browser()->tab_strip_model()->count());
1332 ASSERT_EQ(initial_tab, browser()->tab_strip_model()->GetWebContentsAt(0));
1333
1334 // Check that the appliaction browser has a single tab, and that tab contains
1335 // the content that we app-ified.
1336 ASSERT_EQ(1, app_browser->tab_strip_model()->count());
1337 ASSERT_EQ(app_tab, app_browser->tab_strip_model()->GetWebContentsAt(0));
1338
1339 // Normal tabs should accept load drops.
1340 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops);
1341
1342 // The tab in an app window should not.
1343 EXPECT_FALSE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops);
1344 }
1345
1346 #endif // !defined(OS_MACOSX)
1347
1348 // Test RenderView correctly send back favicon url for web page that redirects 1222 // Test RenderView correctly send back favicon url for web page that redirects
1349 // to an anchor in javascript body.onload handler. 1223 // to an anchor in javascript body.onload handler.
1350 IN_PROC_BROWSER_TEST_F(BrowserTest, 1224 IN_PROC_BROWSER_TEST_F(BrowserTest,
1351 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { 1225 DISABLED_FaviconOfOnloadRedirectToAnchorPage) {
1352 ASSERT_TRUE(embedded_test_server()->Start()); 1226 ASSERT_TRUE(embedded_test_server()->Start());
1353 GURL url(embedded_test_server()->GetURL("/onload_redirect_to_anchor.html")); 1227 GURL url(embedded_test_server()->GetURL("/onload_redirect_to_anchor.html"));
1354 GURL expected_favicon_url(embedded_test_server()->GetURL("/test.png")); 1228 GURL expected_favicon_url(embedded_test_server()->GetURL("/test.png"));
1355 1229
1356 ui_test_utils::NavigateToURL(browser(), url); 1230 ui_test_utils::NavigateToURL(browser(), url);
1357 1231
(...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 Browser* browser = new Browser(params); 2869 Browser* browser = new Browser(params);
2996 gfx::Rect bounds = browser->window()->GetBounds(); 2870 gfx::Rect bounds = browser->window()->GetBounds();
2997 2871
2998 // Should be EXPECT_EQ, but this width is inconsistent across platforms. 2872 // Should be EXPECT_EQ, but this width is inconsistent across platforms.
2999 // See https://crbug.com/567925. 2873 // See https://crbug.com/567925.
3000 EXPECT_GE(bounds.width(), 100); 2874 EXPECT_GE(bounds.width(), 100);
3001 EXPECT_EQ(122, bounds.height()); 2875 EXPECT_EQ(122, bounds.height());
3002 browser->window()->Close(); 2876 browser->window()->Close();
3003 } 2877 }
3004 } 2878 }
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | chrome/browser/ui/browser_command_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698