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