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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 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/stringprintf.h" 6 #include "base/stringprintf.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" 8 #include "chrome/browser/autocomplete/autocomplete_edit.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 9 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/instant/instant_controller.h" 10 #include "chrome/browser/instant/instant_controller.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 void SetupInstantProvider(const std::string& page) { 46 void SetupInstantProvider(const std::string& page) {
47 TemplateURLService* model = 47 TemplateURLService* model =
48 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 48 TemplateURLServiceFactory::GetForProfile(browser()->profile());
49 ASSERT_TRUE(model); 49 ASSERT_TRUE(model);
50 50
51 if (!model->loaded()) { 51 if (!model->loaded()) {
52 model->Load(); 52 model->Load();
53 ui_test_utils::WaitForNotification( 53 ui_test_utils::WaitForNotification(
54 NotificationType::TEMPLATE_URL_SERVICE_LOADED); 54 chrome::TEMPLATE_URL_SERVICE_LOADED);
55 } 55 }
56 56
57 ASSERT_TRUE(model->loaded()); 57 ASSERT_TRUE(model->loaded());
58 58
59 // TemplateURLService takes ownership of this. 59 // TemplateURLService takes ownership of this.
60 TemplateURL* template_url = new TemplateURL(); 60 TemplateURL* template_url = new TemplateURL();
61 61
62 std::string url = StringPrintf( 62 std::string url = StringPrintf(
63 "http://%s:%d/files/instant/%s?q={searchTerms}", 63 "http://%s:%d/files/instant/%s?q={searchTerms}",
64 test_server()->host_port_pair().host().c_str(), 64 test_server()->host_port_pair().host().c_str(),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // When the page loads, the initial searchBox values are set and only a 116 // When the page loads, the initial searchBox values are set and only a
117 // resize will have been sent. 117 // resize will have been sent.
118 ASSERT_EQ("true 0 0 0 1 d false d false 1 1", 118 ASSERT_EQ("true 0 0 0 1 d false d false 1 1",
119 GetSearchStateAsString(preview_, false)); 119 GetSearchStateAsString(preview_, false));
120 } 120 }
121 121
122 void SetLocationBarText(const std::string& text) { 122 void SetLocationBarText(const std::string& text) {
123 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); 123 ASSERT_NO_FATAL_FAILURE(FindLocationBar());
124 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(text)); 124 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(text));
125 ui_test_utils::WaitForNotification( 125 ui_test_utils::WaitForNotification(
126 NotificationType::INSTANT_CONTROLLER_SHOWN); 126 chrome::INSTANT_CONTROLLER_SHOWN);
127 } 127 }
128 128
129 const string16& GetSuggestion() const { 129 const string16& GetSuggestion() const {
130 return browser()->instant()->loader_manager_-> 130 return browser()->instant()->loader_manager_->
131 current_loader()->complete_suggested_text_; 131 current_loader()->complete_suggested_text_;
132 } 132 }
133 133
134 void SendKey(ui::KeyboardCode key) { 134 void SendKey(ui::KeyboardCode key) {
135 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 135 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
136 browser(), key, false, false, false, false)); 136 browser(), key, false, false, false, false));
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 // results. 592 // results.
593 EXPECT_TRUE(browser()->instant()->IsShowingInstant()); 593 EXPECT_TRUE(browser()->instant()->IsShowingInstant());
594 // But because we're waiting to determine if the page really supports instant 594 // But because we're waiting to determine if the page really supports instant
595 // we shouldn't be showing the preview. 595 // we shouldn't be showing the preview.
596 EXPECT_FALSE(browser()->instant()->is_displayable()); 596 EXPECT_FALSE(browser()->instant()->is_displayable());
597 // But instant should still be active. 597 // But instant should still be active.
598 EXPECT_TRUE(browser()->instant()->is_active()); 598 EXPECT_TRUE(browser()->instant()->is_active());
599 599
600 // When the response comes back that the page doesn't support instant the tab 600 // When the response comes back that the page doesn't support instant the tab
601 // should be closed. 601 // should be closed.
602 ui_test_utils::WaitForNotification(NotificationType::TAB_CLOSED); 602 ui_test_utils::WaitForNotification(chrome::TAB_CLOSED);
603 EXPECT_FALSE(browser()->instant()->IsShowingInstant()); 603 EXPECT_FALSE(browser()->instant()->IsShowingInstant());
604 EXPECT_FALSE(browser()->instant()->is_displayable()); 604 EXPECT_FALSE(browser()->instant()->is_displayable());
605 EXPECT_TRUE(browser()->instant()->is_active()); 605 EXPECT_TRUE(browser()->instant()->is_active());
606 EXPECT_FALSE(browser()->instant()->IsCurrent()); 606 EXPECT_FALSE(browser()->instant()->IsCurrent());
607 } 607 }
608 608
609 // Verifies transitioning from loading a non-search string to a search string 609 // Verifies transitioning from loading a non-search string to a search string
610 // with the provider not supporting instant works (meaning we don't display 610 // with the provider not supporting instant works (meaning we don't display
611 // anything). 611 // anything).
612 #if defined(OS_MACOSX) || defined(OS_LINUX) 612 #if defined(OS_MACOSX) || defined(OS_LINUX)
(...skipping 29 matching lines...) Expand all
642 ASSERT_TRUE(browser()->instant()->is_displayable()); 642 ASSERT_TRUE(browser()->instant()->is_displayable());
643 ASSERT_TRUE(browser()->instant()->is_active()); 643 ASSERT_TRUE(browser()->instant()->is_active());
644 // Because we typed in a search string we should think we're showing instant 644 // Because we typed in a search string we should think we're showing instant
645 // results. 645 // results.
646 EXPECT_TRUE(browser()->instant()->MightSupportInstant()); 646 EXPECT_TRUE(browser()->instant()->MightSupportInstant());
647 // Instant should not be current (it's still loading). 647 // Instant should not be current (it's still loading).
648 EXPECT_FALSE(browser()->instant()->IsCurrent()); 648 EXPECT_FALSE(browser()->instant()->IsCurrent());
649 649
650 // When the response comes back that the page doesn't support instant the tab 650 // When the response comes back that the page doesn't support instant the tab
651 // should be closed. 651 // should be closed.
652 ui_test_utils::WaitForNotification(NotificationType::TAB_CLOSED); 652 ui_test_utils::WaitForNotification(chrome::TAB_CLOSED);
653 EXPECT_FALSE(browser()->instant()->IsShowingInstant()); 653 EXPECT_FALSE(browser()->instant()->IsShowingInstant());
654 EXPECT_FALSE(browser()->instant()->is_displayable()); 654 EXPECT_FALSE(browser()->instant()->is_displayable());
655 // But because the omnibox is still open, instant should be active. 655 // But because the omnibox is still open, instant should be active.
656 ASSERT_TRUE(browser()->instant()->is_active()); 656 ASSERT_TRUE(browser()->instant()->is_active());
657 } 657 }
658 658
659 // Verifies the page was told a non-zero height. 659 // Verifies the page was told a non-zero height.
660 // DISABLED http://crbug.com/80118 660 // DISABLED http://crbug.com/80118
661 #if defined(OS_LINUX) 661 #if defined(OS_LINUX)
662 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_ValidHeight) { 662 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_ValidHeight) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 EnableInstant(); 698 EnableInstant();
699 GURL url(test_server()->GetURL("files/instant/403.html")); 699 GURL url(test_server()->GetURL("files/instant/403.html"));
700 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); 700 ASSERT_NO_FATAL_FAILURE(FindLocationBar());
701 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); 701 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec()));
702 // The preview shouldn't be showing, but it should be loading. 702 // The preview shouldn't be showing, but it should be loading.
703 ASSERT_TRUE(browser()->instant()->GetPreviewContents()); 703 ASSERT_TRUE(browser()->instant()->GetPreviewContents());
704 ASSERT_TRUE(browser()->instant()->is_active()); 704 ASSERT_TRUE(browser()->instant()->is_active());
705 ASSERT_FALSE(browser()->instant()->is_displayable()); 705 ASSERT_FALSE(browser()->instant()->is_displayable());
706 706
707 // When instant sees the 403, it should close the tab. 707 // When instant sees the 403, it should close the tab.
708 ui_test_utils::WaitForNotification(NotificationType::TAB_CLOSED); 708 ui_test_utils::WaitForNotification(chrome::TAB_CLOSED);
709 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); 709 ASSERT_FALSE(browser()->instant()->GetPreviewContents());
710 ASSERT_TRUE(browser()->instant()->is_active()); 710 ASSERT_TRUE(browser()->instant()->is_active());
711 ASSERT_FALSE(browser()->instant()->is_displayable()); 711 ASSERT_FALSE(browser()->instant()->is_displayable());
712 712
713 // Try loading another url on the server. Instant shouldn't create a new tab 713 // Try loading another url on the server. Instant shouldn't create a new tab
714 // as the server returned 403. 714 // as the server returned 403.
715 GURL url2(test_server()->GetURL("files/instant/empty.html")); 715 GURL url2(test_server()->GetURL("files/instant/empty.html"));
716 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url2.spec())); 716 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url2.spec()));
717 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); 717 ASSERT_FALSE(browser()->instant()->GetPreviewContents());
718 ASSERT_TRUE(browser()->instant()->is_active()); 718 ASSERT_TRUE(browser()->instant()->is_active());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 IN_PROC_BROWSER_TEST_F(InstantTest, DontCrashOnBlockedJS) { 862 IN_PROC_BROWSER_TEST_F(InstantTest, DontCrashOnBlockedJS) {
863 #endif // OS_LINUX 863 #endif // OS_LINUX
864 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 864 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
865 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); 865 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK);
866 ASSERT_TRUE(test_server()->Start()); 866 ASSERT_TRUE(test_server()->Start());
867 EnableInstant(); 867 EnableInstant();
868 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); 868 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html"));
869 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); 869 ASSERT_NO_FATAL_FAILURE(SetupLocationBar());
870 // Wait for notification that the instant API has been determined. 870 // Wait for notification that the instant API has been determined.
871 ui_test_utils::WaitForNotification( 871 ui_test_utils::WaitForNotification(
872 NotificationType::INSTANT_SUPPORT_DETERMINED); 872 chrome::INSTANT_SUPPORT_DETERMINED);
873 // As long as we get the notification we're good (the renderer didn't crash). 873 // As long as we get the notification we're good (the renderer didn't crash).
874 } 874 }
875 875
876 // DISABLED http://crbug.com/80118 876 // DISABLED http://crbug.com/80118
877 #if defined(OS_LINUX) 877 #if defined(OS_LINUX)
878 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_DownloadOnEnter) { 878 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_DownloadOnEnter) {
879 #else 879 #else
880 IN_PROC_BROWSER_TEST_F(InstantTest, DownloadOnEnter) { 880 IN_PROC_BROWSER_TEST_F(InstantTest, DownloadOnEnter) {
881 #endif // OS_LINUX 881 #endif // OS_LINUX
882 ASSERT_TRUE(test_server()->Start()); 882 ASSERT_TRUE(test_server()->Start());
883 EnableInstant(); 883 EnableInstant();
884 // Make sure the browser window is the front most window. 884 // Make sure the browser window is the front most window.
885 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 885 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
886 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); 886 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html"));
887 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); 887 ASSERT_NO_FATAL_FAILURE(FindLocationBar());
888 GURL url(test_server()->GetURL("files/instant/empty.html")); 888 GURL url(test_server()->GetURL("files/instant/empty.html"));
889 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); 889 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec()));
890 printf("0\n"); 890 printf("0\n");
891 ASSERT_NO_FATAL_FAILURE(WaitForPreviewToNavigate(true)); 891 ASSERT_NO_FATAL_FAILURE(WaitForPreviewToNavigate(true));
892 url = test_server()->GetURL("files/instant/download.zip"); 892 url = test_server()->GetURL("files/instant/download.zip");
893 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); 893 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec()));
894 // Wait for the load to fail (because instant disables downloads). 894 // Wait for the load to fail (because instant disables downloads).
895 printf("1\n"); 895 printf("1\n");
896 ui_test_utils::WaitForNotification( 896 ui_test_utils::WaitForNotification(
897 NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR); 897 chrome::FAIL_PROVISIONAL_LOAD_WITH_ERROR);
898 898
899 printf("2\n"); 899 printf("2\n");
900 ui_test_utils::WindowedNotificationObserver download_observer( 900 ui_test_utils::WindowedNotificationObserver download_observer(
901 NotificationType::DOWNLOAD_INITIATED, 901 chrome::DOWNLOAD_INITIATED,
902 NotificationService::AllSources()); 902 NotificationService::AllSources());
903 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN)); 903 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN));
904 printf("3\n"); 904 printf("3\n");
905 download_observer.Wait(); 905 download_observer.Wait();
906 printf("4\n"); 906 printf("4\n");
907 907
908 // And we should end up at about:blank. 908 // And we should end up at about:blank.
909 TabContents* contents = browser()->GetSelectedTabContents(); 909 TabContents* contents = browser()->GetSelectedTabContents();
910 ASSERT_TRUE(contents); 910 ASSERT_TRUE(contents);
911 EXPECT_EQ("about:blank", 911 EXPECT_EQ("about:blank",
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 ui_test_utils::NavigateToURL( 946 ui_test_utils::NavigateToURL(
947 browser(), 947 browser(),
948 GURL(test_server()->GetURL("files/instant/empty.html"))); 948 GURL(test_server()->GetURL("files/instant/empty.html")));
949 bool result; 949 bool result;
950 ASSERT_TRUE(GetBoolFromJavascript( 950 ASSERT_TRUE(GetBoolFromJavascript(
951 browser()->GetSelectedTabContents(), 951 browser()->GetSelectedTabContents(),
952 "window.chrome.searchBox.value.length == 0", 952 "window.chrome.searchBox.value.length == 0",
953 &result)); 953 &result));
954 EXPECT_TRUE(result); 954 EXPECT_TRUE(result);
955 } 955 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698