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

Side by Side Diff: chrome/browser/ui/search/instant_extended_interactive_uitest.cc

Issue 48713008: [sync] Allow FakeURLFetcher to return arbitrary HTTP response codes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_base.h" 8 #include "base/metrics/histogram_base.h"
9 #include "base/metrics/histogram_samples.h" 9 #include "base/metrics/histogram_samples.h"
10 #include "base/metrics/statistics_recorder.h" 10 #include "base/metrics/statistics_recorder.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "content/public/browser/render_view_host.h" 69 #include "content/public/browser/render_view_host.h"
70 #include "content/public/browser/site_instance.h" 70 #include "content/public/browser/site_instance.h"
71 #include "content/public/browser/url_data_source.h" 71 #include "content/public/browser/url_data_source.h"
72 #include "content/public/browser/web_contents.h" 72 #include "content/public/browser/web_contents.h"
73 #include "content/public/browser/web_contents_view.h" 73 #include "content/public/browser/web_contents_view.h"
74 #include "content/public/common/bindings_policy.h" 74 #include "content/public/common/bindings_policy.h"
75 #include "content/public/test/browser_test_utils.h" 75 #include "content/public/test/browser_test_utils.h"
76 #include "content/public/test/test_utils.h" 76 #include "content/public/test/test_utils.h"
77 #include "grit/generated_resources.h" 77 #include "grit/generated_resources.h"
78 #include "net/base/network_change_notifier.h" 78 #include "net/base/network_change_notifier.h"
79 #include "net/http/http_status_code.h"
79 #include "net/url_request/test_url_fetcher_factory.h" 80 #include "net/url_request/test_url_fetcher_factory.h"
80 #include "net/url_request/url_fetcher_impl.h" 81 #include "net/url_request/url_fetcher_impl.h"
81 #include "testing/gmock/include/gmock/gmock.h" 82 #include "testing/gmock/include/gmock/gmock.h"
82 #include "third_party/skia/include/core/SkBitmap.h" 83 #include "third_party/skia/include/core/SkBitmap.h"
83 #include "ui/base/l10n/l10n_util.h" 84 #include "ui/base/l10n/l10n_util.h"
84 85
85 using testing::HasSubstr; 86 using testing::HasSubstr;
86 87
87 namespace { 88 namespace {
88 89
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 kMinimumTimeBetweenSuggestQueriesMs = 0; 917 kMinimumTimeBetweenSuggestQueriesMs = 0;
917 918
918 // Set the fake response for suggest request. Response has prefetch details. 919 // Set the fake response for suggest request. Response has prefetch details.
919 // Ensure that the page received the prefetch query. 920 // Ensure that the page received the prefetch query.
920 fake_factory()->SetFakeResponse( 921 fake_factory()->SetFakeResponse(
921 instant_url().Resolve("#q=pupp"), 922 instant_url().Resolve("#q=pupp"),
922 "[\"pupp\",[\"puppy\", \"puppies\"],[],[]," 923 "[\"pupp\",[\"puppy\", \"puppies\"],[],[],"
923 "{\"google:clientdata\":{\"phi\": 0}," 924 "{\"google:clientdata\":{\"phi\": 0},"
924 "\"google:suggesttype\":[\"QUERY\", \"QUERY\"]," 925 "\"google:suggesttype\":[\"QUERY\", \"QUERY\"],"
925 "\"google:suggestrelevance\":[1400, 9]}]", 926 "\"google:suggestrelevance\":[1400, 9]}]",
926 true); 927 net::HTTP_OK);
927 928
928 SetOmniboxText("pupp"); 929 SetOmniboxText("pupp");
929 while (!omnibox()->model()->autocomplete_controller()->done()) { 930 while (!omnibox()->model()->autocomplete_controller()->done()) {
930 content::WindowedNotificationObserver ready_observer( 931 content::WindowedNotificationObserver ready_observer(
931 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 932 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
932 content::Source<AutocompleteController>( 933 content::Source<AutocompleteController>(
933 omnibox()->model()->autocomplete_controller())); 934 omnibox()->model()->autocomplete_controller()));
934 ready_observer.Wait(); 935 ready_observer.Wait();
935 } 936 }
936 937
(...skipping 24 matching lines...) Expand all
961 kMinimumTimeBetweenSuggestQueriesMs = 0; 962 kMinimumTimeBetweenSuggestQueriesMs = 0;
962 963
963 // Set the fake response for suggest request. Response has no prefetch 964 // Set the fake response for suggest request. Response has no prefetch
964 // details. Ensure that the page received a blank query to clear the 965 // details. Ensure that the page received a blank query to clear the
965 // prefetched results. 966 // prefetched results.
966 fake_factory()->SetFakeResponse( 967 fake_factory()->SetFakeResponse(
967 instant_url().Resolve("#q=dogs"), 968 instant_url().Resolve("#q=dogs"),
968 "[\"dogs\",[\"https://dogs.com\"],[],[]," 969 "[\"dogs\",[\"https://dogs.com\"],[],[],"
969 "{\"google:suggesttype\":[\"NAVIGATION\"]," 970 "{\"google:suggesttype\":[\"NAVIGATION\"],"
970 "\"google:suggestrelevance\":[2]}]", 971 "\"google:suggestrelevance\":[2]}]",
971 true); 972 net::HTTP_OK);
972 973
973 SetOmniboxText("dogs"); 974 SetOmniboxText("dogs");
974 while (!omnibox()->model()->autocomplete_controller()->done()) { 975 while (!omnibox()->model()->autocomplete_controller()->done()) {
975 content::WindowedNotificationObserver ready_observer( 976 content::WindowedNotificationObserver ready_observer(
976 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 977 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
977 content::Source<AutocompleteController>( 978 content::Source<AutocompleteController>(
978 omnibox()->model()->autocomplete_controller())); 979 omnibox()->model()->autocomplete_controller()));
979 ready_observer.Wait(); 980 ready_observer.Wait();
980 } 981 }
981 982
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 stream << "link.href = \"" << result_url.spec() << "\";"; 1037 stream << "link.href = \"" << result_url.spec() << "\";";
1037 stream << "document.body.appendChild(link);"; 1038 stream << "document.body.appendChild(link);";
1038 stream << "link.click();"; 1039 stream << "link.click();";
1039 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); 1040 EXPECT_TRUE(content::ExecuteScript(contents, stream.str()));
1040 1041
1041 content::WaitForLoadStop(contents); 1042 content::WaitForLoadStop(contents);
1042 std::string expected_title = 1043 std::string expected_title =
1043 "Referrer is " + instant_url().GetWithEmptyPath().spec(); 1044 "Referrer is " + instant_url().GetWithEmptyPath().spec();
1044 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); 1045 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle());
1045 } 1046 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698