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

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

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 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 | Annotate | Revision Log
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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/sys_info.h" 13 #include "base/sys_info.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/chrome_content_browser_client.h" 15 #include "chrome/browser/chrome_content_browser_client.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/command_updater.h" 17 #include "chrome/browser/command_updater.h"
18 #include "chrome/browser/content_settings/host_content_settings_map.h" 18 #include "chrome/browser/content_settings/host_content_settings_map.h"
19 #include "chrome/browser/defaults.h" 19 #include "chrome/browser/defaults.h"
20 #include "chrome/browser/extensions/extension_browsertest.h" 20 #include "chrome/browser/extensions/extension_browsertest.h"
21 #include "chrome/browser/extensions/extension_service.h" 21 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/extension_system.h" 22 #include "chrome/browser/extensions/extension_system.h"
23 #include "chrome/browser/extensions/tab_helper.h" 23 #include "chrome/browser/extensions/tab_helper.h"
24 #include "chrome/browser/first_run/first_run.h" 24 #include "chrome/browser/first_run/first_run.h"
25 #include "chrome/browser/lifetime/application_lifetime.h" 25 #include "chrome/browser/lifetime/application_lifetime.h"
26 #include "chrome/browser/prefs/incognito_mode_prefs.h" 26 #include "chrome/browser/prefs/incognito_mode_prefs.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/search/instant_service.h"
30 #include "chrome/browser/search/instant_service_factory.h"
29 #include "chrome/browser/search/search.h" 31 #include "chrome/browser/search/search.h"
30 #include "chrome/browser/sessions/session_backend.h" 32 #include "chrome/browser/sessions/session_backend.h"
31 #include "chrome/browser/sessions/session_service_factory.h" 33 #include "chrome/browser/sessions/session_service_factory.h"
32 #include "chrome/browser/translate/translate_tab_helper.h" 34 #include "chrome/browser/translate/translate_tab_helper.h"
33 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 35 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 36 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
35 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" 37 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
36 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 38 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
37 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
38 #include "chrome/browser/ui/browser_command_controller.h" 40 #include "chrome/browser/ui/browser_command_controller.h"
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 // Test that get_process_idle_time() returns reasonable values when compared 935 // Test that get_process_idle_time() returns reasonable values when compared
934 // with time deltas measured locally. 936 // with time deltas measured locally.
935 IN_PROC_BROWSER_TEST_F(BrowserTest, RenderIdleTime) { 937 IN_PROC_BROWSER_TEST_F(BrowserTest, RenderIdleTime) {
936 base::TimeTicks start = base::TimeTicks::Now(); 938 base::TimeTicks start = base::TimeTicks::Now();
937 ui_test_utils::NavigateToURL( 939 ui_test_utils::NavigateToURL(
938 browser(), ui_test_utils::GetTestUrl( 940 browser(), ui_test_utils::GetTestUrl(
939 base::FilePath(base::FilePath::kCurrentDirectory), 941 base::FilePath(base::FilePath::kCurrentDirectory),
940 base::FilePath(kTitle1File))); 942 base::FilePath(kTitle1File)));
941 content::RenderProcessHost::iterator it( 943 content::RenderProcessHost::iterator it(
942 content::RenderProcessHost::AllHostsIterator()); 944 content::RenderProcessHost::AllHostsIterator());
945 const InstantService* instant_service =
946 InstantServiceFactory::GetForProfile(browser()->profile());
943 for (; !it.IsAtEnd(); it.Advance()) { 947 for (; !it.IsAtEnd(); it.Advance()) {
948 // Ignore renderers in the Instant process (that may have been prerendered).
949 if (instant_service && instant_service->IsInstantProcess(
950 it.GetCurrentValue()->GetID())) {
951 continue;
952 }
944 base::TimeDelta renderer_td = 953 base::TimeDelta renderer_td =
945 it.GetCurrentValue()->GetChildProcessIdleTime(); 954 it.GetCurrentValue()->GetChildProcessIdleTime();
946 base::TimeDelta browser_td = base::TimeTicks::Now() - start; 955 base::TimeDelta browser_td = base::TimeTicks::Now() - start;
947 EXPECT_TRUE(browser_td >= renderer_td); 956 EXPECT_TRUE(browser_td >= renderer_td);
948 } 957 }
949 } 958 }
950 959
951 // Test IDC_CREATE_SHORTCUTS command is enabled for url scheme file, ftp, http 960 // Test IDC_CREATE_SHORTCUTS command is enabled for url scheme file, ftp, http
952 // and https and disabled for chrome://, about:// etc. 961 // and https and disabled for chrome://, about:// etc.
953 // TODO(pinkerton): Disable app-mode in the model until we implement it 962 // TODO(pinkerton): Disable app-mode in the model until we implement it
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 ui_test_utils::NavigateToURL(browser(), ftp_url); 1013 ui_test_utils::NavigateToURL(browser(), ftp_url);
1005 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 1014 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1006 } 1015 }
1007 1016
1008 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) { 1017 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) {
1009 CommandUpdater* command_updater = 1018 CommandUpdater* command_updater =
1010 browser()->command_controller()->command_updater(); 1019 browser()->command_controller()->command_updater();
1011 1020
1012 // Urls that should not have shortcuts. 1021 // Urls that should not have shortcuts.
1013 GURL new_tab_url(chrome::kChromeUINewTabURL); 1022 GURL new_tab_url(chrome::kChromeUINewTabURL);
1014 ui_test_utils::NavigateToURL(browser(), new_tab_url); 1023 ui_test_utils::NavigateToURLWithDisposition(
1024 browser(), new_tab_url, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
1015 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 1025 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1016 1026
1017 GURL history_url(chrome::kChromeUIHistoryURL); 1027 GURL history_url(chrome::kChromeUIHistoryURL);
1018 ui_test_utils::NavigateToURL(browser(), history_url); 1028 ui_test_utils::NavigateToURL(browser(), history_url);
1019 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 1029 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1020 1030
1021 GURL downloads_url(chrome::kChromeUIDownloadsURL); 1031 GURL downloads_url(chrome::kChromeUIDownloadsURL);
1022 ui_test_utils::NavigateToURL(browser(), downloads_url); 1032 ui_test_utils::NavigateToURL(browser(), downloads_url);
1023 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 1033 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
1024 1034
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 #endif 2426 #endif
2417 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_GetSizeForNewRenderView) { 2427 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_GetSizeForNewRenderView) {
2418 ASSERT_TRUE(test_server()->Start()); 2428 ASSERT_TRUE(test_server()->Start());
2419 // Create an HTTPS server for cross-site transition. 2429 // Create an HTTPS server for cross-site transition.
2420 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, 2430 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS,
2421 net::SpawnedTestServer::kLocalhost, 2431 net::SpawnedTestServer::kLocalhost,
2422 base::FilePath(kDocRoot)); 2432 base::FilePath(kDocRoot));
2423 ASSERT_TRUE(https_test_server.Start()); 2433 ASSERT_TRUE(https_test_server.Start());
2424 2434
2425 // Start with NTP. 2435 // Start with NTP.
2426 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); 2436 ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal://newtab"));
2427 ASSERT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); 2437 ASSERT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state());
2428 WebContents* web_contents = 2438 WebContents* web_contents =
2429 browser()->tab_strip_model()->GetActiveWebContents(); 2439 browser()->tab_strip_model()->GetActiveWebContents();
2430 content::RenderViewHost* prev_rvh = web_contents->GetRenderViewHost(); 2440 content::RenderViewHost* prev_rvh = web_contents->GetRenderViewHost();
2431 const int height_inset = 2441 const int height_inset =
2432 browser()->window()->GetRenderViewHeightInsetWithDetachedBookmarkBar(); 2442 browser()->window()->GetRenderViewHeightInsetWithDetachedBookmarkBar();
2433 const gfx::Size initial_wcv_size = 2443 const gfx::Size initial_wcv_size =
2434 web_contents->GetView()->GetContainerSize(); 2444 web_contents->GetView()->GetContainerSize();
2435 RenderViewSizeObserver observer(web_contents, browser()->window()); 2445 RenderViewSizeObserver observer(web_contents, browser()->window());
2436 2446
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 &rwhv_create_size1, 2483 &rwhv_create_size1,
2474 &rwhv_commit_size1, 2484 &rwhv_commit_size1,
2475 &wcv_commit_size1); 2485 &wcv_commit_size1);
2476 EXPECT_EQ(rwhv_create_size1, rwhv_commit_size1); 2486 EXPECT_EQ(rwhv_create_size1, rwhv_commit_size1);
2477 EXPECT_EQ(rwhv_commit_size1, 2487 EXPECT_EQ(rwhv_commit_size1,
2478 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2488 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2479 EXPECT_EQ(wcv_commit_size1, web_contents->GetView()->GetContainerSize()); 2489 EXPECT_EQ(wcv_commit_size1, web_contents->GetView()->GetContainerSize());
2480 2490
2481 // Navigate from NTP to a non-NTP page, resizing WebContentsView while 2491 // Navigate from NTP to a non-NTP page, resizing WebContentsView while
2482 // navigation entry is pending. 2492 // navigation entry is pending.
2483 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); 2493 ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal://newtab"));
2484 gfx::Size wcv_resize_insets(-34, -57); 2494 gfx::Size wcv_resize_insets(-34, -57);
2485 observer.set_wcv_resize_insets(wcv_resize_insets); 2495 observer.set_wcv_resize_insets(wcv_resize_insets);
2486 ui_test_utils::NavigateToURL(browser(), 2496 ui_test_utils::NavigateToURL(browser(),
2487 test_server()->GetURL("files/title2.html")); 2497 test_server()->GetURL("files/title2.html"));
2488 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); 2498 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state());
2489 gfx::Size rwhv_create_size2, rwhv_commit_size2, wcv_commit_size2; 2499 gfx::Size rwhv_create_size2, rwhv_commit_size2, wcv_commit_size2;
2490 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), 2500 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(),
2491 &rwhv_create_size2, 2501 &rwhv_create_size2,
2492 &rwhv_commit_size2, 2502 &rwhv_commit_size2,
2493 &wcv_commit_size2); 2503 &wcv_commit_size2);
2494 // The create height of RenderWidgetHostView should include the height inset. 2504 // The create height of RenderWidgetHostView should include the height inset.
2495 EXPECT_EQ(gfx::Size(initial_wcv_size.width(), 2505 EXPECT_EQ(gfx::Size(initial_wcv_size.width(),
2496 initial_wcv_size.height() + height_inset), 2506 initial_wcv_size.height() + height_inset),
2497 rwhv_create_size2); 2507 rwhv_create_size2);
2498 // WebContentsView was resized in 2508 // WebContentsView was resized in
2499 // RenderViewSizeObserver::NavigateToPendingEntry after RenderWidgetHostView 2509 // RenderViewSizeObserver::NavigateToPendingEntry after RenderWidgetHostView
2500 // was created, so the commit size should be resized accordingly. 2510 // was created, so the commit size should be resized accordingly.
2501 gfx::Size exp_commit_size(initial_wcv_size); 2511 gfx::Size exp_commit_size(initial_wcv_size);
2502 exp_commit_size.Enlarge(wcv_resize_insets.width(), 2512 exp_commit_size.Enlarge(wcv_resize_insets.width(),
2503 wcv_resize_insets.height() + height_inset); 2513 wcv_resize_insets.height() + height_inset);
2504 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2514 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2505 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2515 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2506 // Sizes of RenderWidgetHostView and WebContentsView before and after 2516 // Sizes of RenderWidgetHostView and WebContentsView before and after
2507 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same. 2517 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same.
2508 EXPECT_EQ(rwhv_commit_size2, 2518 EXPECT_EQ(rwhv_commit_size2,
2509 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2519 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2510 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize()); 2520 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize());
2511 } 2521 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698