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

Side by Side Diff: chrome/browser/instant/instant_browsertest.cc

Issue 8759009: Add "Instant:" prefix to Instant preview tabs in the Task manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cache is_instant_preview Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/string_util.h"
6 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
7 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" 9 #include "chrome/browser/autocomplete/autocomplete_edit.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/instant/instant_controller.h" 11 #include "chrome/browser/instant/instant_controller.h"
11 #include "chrome/browser/instant/instant_loader.h" 12 #include "chrome/browser/instant/instant_loader.h"
12 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/search_engines/template_url.h" 15 #include "chrome/browser/search_engines/template_url.h"
15 #include "chrome/browser/search_engines/template_url_service.h" 16 #include "chrome/browser/search_engines/template_url_service.h"
16 #include "chrome/browser/search_engines/template_url_service_factory.h" 17 #include "chrome/browser/search_engines/template_url_service_factory.h"
18 #include "chrome/browser/task_manager/task_manager.h"
19 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
17 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/omnibox/location_bar.h" 22 #include "chrome/browser/ui/omnibox/location_bar.h"
20 #include "chrome/browser/ui/omnibox/omnibox_view.h" 23 #include "chrome/browser/ui/omnibox/omnibox_view.h"
21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
22 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
26 #include "chrome/test/base/in_process_browser_test.h" 29 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
28 #include "content/browser/renderer_host/render_view_host.h" 31 #include "content/browser/renderer_host/render_view_host.h"
29 #include "content/browser/renderer_host/render_widget_host_view.h" 32 #include "content/browser/renderer_host/render_widget_host_view.h"
30 #include "content/browser/tab_contents/tab_contents.h" 33 #include "content/browser/tab_contents/tab_contents.h"
31 #include "content/public/browser/notification_service.h" 34 #include "content/public/browser/notification_service.h"
35 #include "grit/generated_resources.h"
36 #include "ui/base/l10n/l10n_util.h"
32 37
33 // Tests are flaky on Linux because of http://crbug.com/80118. 38 // Tests are flaky on Linux because of http://crbug.com/80118.
34 #if defined(OS_LINUX) 39 #if defined(OS_LINUX)
35 #define MAYBE(TestName) DISABLED_ ## TestName 40 #define MAYBE(TestName) DISABLED_ ## TestName
36 #else 41 #else
37 #define MAYBE(TestName) TestName 42 #define MAYBE(TestName) TestName
38 #endif 43 #endif
39 44
40 class InstantTest : public InProcessBrowserTest { 45 class InstantTest : public InProcessBrowserTest {
41 public: 46 public:
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 omnibox()->SetUserText(ASCIIToUTF16("def")); 800 omnibox()->SetUserText(ASCIIToUTF16("def"));
796 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true)); 801 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true));
797 ASSERT_TRUE(CheckVisibilityIs(initial_contents, false)); 802 ASSERT_TRUE(CheckVisibilityIs(initial_contents, false));
798 803
799 // Commit the preview. 804 // Commit the preview.
800 ASSERT_TRUE(PressEnter()); 805 ASSERT_TRUE(PressEnter());
801 EXPECT_EQ(preview_contents, browser()->GetSelectedTabContents()); 806 EXPECT_EQ(preview_contents, browser()->GetSelectedTabContents());
802 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true)); 807 ASSERT_TRUE(CheckVisibilityIs(preview_contents, true));
803 } 808 }
804 809
810 // Tests that the task manager identifies instant's preview tab correctly.
811 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(TaskManagerPrefix)) {
812 // The browser starts with one new tab, so the task manager should have two
813 // rows initially, one for the browser process and one for tab's renderer.
814 TaskManagerModel* task_manager = TaskManager::GetInstance()->model();
815 task_manager->StartUpdating();
816 TaskManagerBrowserTestUtil::WaitForResourceChange(2);
817
818 ASSERT_TRUE(test_server()->Start());
819 EnableInstant();
820 SetupInstantProvider("instant.html");
821 DetermineInstantSupport();
822 SearchAndWaitForPreviewToShow();
823
824 // Now there should be three rows, the third being the instant preview.
825 TaskManagerBrowserTestUtil::WaitForResourceChange(3);
826 string16 prefix = l10n_util::GetStringFUTF16(
827 IDS_TASK_MANAGER_INSTANT_PREVIEW_PREFIX, string16());
828 string16 title = task_manager->GetResourceTitle(2);
829 EXPECT_TRUE(StartsWith(title, prefix, true)) << title << " vs " << prefix;
830 }
831
805 // Tests the INSTANT experiment of the field trial. 832 // Tests the INSTANT experiment of the field trial.
806 class InstantFieldTrialInstantTest : public InstantTest { 833 class InstantFieldTrialInstantTest : public InstantTest {
807 public: 834 public:
808 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 835 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
809 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, 836 command_line->AppendSwitchASCII(switches::kInstantFieldTrial,
810 switches::kInstantFieldTrialInstant); 837 switches::kInstantFieldTrialInstant);
811 } 838 }
812 }; 839 };
813 840
814 // Tests that instant is active, even without calling EnableInstant(). 841 // Tests that instant is active, even without calling EnableInstant().
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 // Press <Enter> in the omnibox, causing the preview to be committed. 998 // Press <Enter> in the omnibox, causing the preview to be committed.
972 TabContents* preview_tab = preview()->tab_contents(); 999 TabContents* preview_tab = preview()->tab_contents();
973 ASSERT_TRUE(PressEnter()); 1000 ASSERT_TRUE(PressEnter());
974 1001
975 // The preview contents should now be the active tab contents. 1002 // The preview contents should now be the active tab contents.
976 EXPECT_FALSE(preview()); 1003 EXPECT_FALSE(preview());
977 EXPECT_FALSE(instant()->is_displayable()); 1004 EXPECT_FALSE(instant()->is_displayable());
978 EXPECT_FALSE(instant()->IsCurrent()); 1005 EXPECT_FALSE(instant()->IsCurrent());
979 EXPECT_EQ(preview_tab, browser()->GetSelectedTabContents()); 1006 EXPECT_EQ(preview_tab, browser()->GetSelectedTabContents());
980 } 1007 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/task_manager/task_manager_resource_providers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698