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

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

Issue 60923002: [sync] Allow FakeURLFetcher to return an arbitrary URLRequestStatus (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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/http/http_status_code.h"
80 #include "net/url_request/test_url_fetcher_factory.h" 80 #include "net/url_request/test_url_fetcher_factory.h"
81 #include "net/url_request/url_fetcher_impl.h" 81 #include "net/url_request/url_fetcher_impl.h"
82 #include "net/url_request/url_request_status.h"
82 #include "testing/gmock/include/gmock/gmock.h" 83 #include "testing/gmock/include/gmock/gmock.h"
83 #include "third_party/skia/include/core/SkBitmap.h" 84 #include "third_party/skia/include/core/SkBitmap.h"
84 #include "ui/base/l10n/l10n_util.h" 85 #include "ui/base/l10n/l10n_util.h"
85 86
86 using testing::HasSubstr; 87 using testing::HasSubstr;
87 88
88 namespace { 89 namespace {
89 90
90 // Creates a bitmap of the specified color. Caller takes ownership. 91 // Creates a bitmap of the specified color. Caller takes ownership.
91 gfx::Image CreateBitmap(SkColor color) { 92 gfx::Image CreateBitmap(SkColor color) {
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 kMinimumTimeBetweenSuggestQueriesMs = 0; 918 kMinimumTimeBetweenSuggestQueriesMs = 0;
918 919
919 // Set the fake response for suggest request. Response has prefetch details. 920 // Set the fake response for suggest request. Response has prefetch details.
920 // Ensure that the page received the prefetch query. 921 // Ensure that the page received the prefetch query.
921 fake_factory()->SetFakeResponse( 922 fake_factory()->SetFakeResponse(
922 instant_url().Resolve("#q=pupp"), 923 instant_url().Resolve("#q=pupp"),
923 "[\"pupp\",[\"puppy\", \"puppies\"],[],[]," 924 "[\"pupp\",[\"puppy\", \"puppies\"],[],[],"
924 "{\"google:clientdata\":{\"phi\": 0}," 925 "{\"google:clientdata\":{\"phi\": 0},"
925 "\"google:suggesttype\":[\"QUERY\", \"QUERY\"]," 926 "\"google:suggesttype\":[\"QUERY\", \"QUERY\"],"
926 "\"google:suggestrelevance\":[1400, 9]}]", 927 "\"google:suggestrelevance\":[1400, 9]}]",
927 net::HTTP_OK); 928 net::HTTP_OK,
929 net::URLRequestStatus::SUCCESS);
928 930
929 SetOmniboxText("pupp"); 931 SetOmniboxText("pupp");
930 while (!omnibox()->model()->autocomplete_controller()->done()) { 932 while (!omnibox()->model()->autocomplete_controller()->done()) {
931 content::WindowedNotificationObserver ready_observer( 933 content::WindowedNotificationObserver ready_observer(
932 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 934 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
933 content::Source<AutocompleteController>( 935 content::Source<AutocompleteController>(
934 omnibox()->model()->autocomplete_controller())); 936 omnibox()->model()->autocomplete_controller()));
935 ready_observer.Wait(); 937 ready_observer.Wait();
936 } 938 }
937 939
(...skipping 24 matching lines...) Expand all
962 kMinimumTimeBetweenSuggestQueriesMs = 0; 964 kMinimumTimeBetweenSuggestQueriesMs = 0;
963 965
964 // Set the fake response for suggest request. Response has no prefetch 966 // Set the fake response for suggest request. Response has no prefetch
965 // details. Ensure that the page received a blank query to clear the 967 // details. Ensure that the page received a blank query to clear the
966 // prefetched results. 968 // prefetched results.
967 fake_factory()->SetFakeResponse( 969 fake_factory()->SetFakeResponse(
968 instant_url().Resolve("#q=dogs"), 970 instant_url().Resolve("#q=dogs"),
969 "[\"dogs\",[\"https://dogs.com\"],[],[]," 971 "[\"dogs\",[\"https://dogs.com\"],[],[],"
970 "{\"google:suggesttype\":[\"NAVIGATION\"]," 972 "{\"google:suggesttype\":[\"NAVIGATION\"],"
971 "\"google:suggestrelevance\":[2]}]", 973 "\"google:suggestrelevance\":[2]}]",
972 net::HTTP_OK); 974 net::HTTP_OK,
975 net::URLRequestStatus::SUCCESS);
973 976
974 SetOmniboxText("dogs"); 977 SetOmniboxText("dogs");
975 while (!omnibox()->model()->autocomplete_controller()->done()) { 978 while (!omnibox()->model()->autocomplete_controller()->done()) {
976 content::WindowedNotificationObserver ready_observer( 979 content::WindowedNotificationObserver ready_observer(
977 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 980 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
978 content::Source<AutocompleteController>( 981 content::Source<AutocompleteController>(
979 omnibox()->model()->autocomplete_controller())); 982 omnibox()->model()->autocomplete_controller()));
980 ready_observer.Wait(); 983 ready_observer.Wait();
981 } 984 }
982 985
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 stream << "link.href = \"" << result_url.spec() << "\";"; 1040 stream << "link.href = \"" << result_url.spec() << "\";";
1038 stream << "document.body.appendChild(link);"; 1041 stream << "document.body.appendChild(link);";
1039 stream << "link.click();"; 1042 stream << "link.click();";
1040 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); 1043 EXPECT_TRUE(content::ExecuteScript(contents, stream.str()));
1041 1044
1042 content::WaitForLoadStop(contents); 1045 content::WaitForLoadStop(contents);
1043 std::string expected_title = 1046 std::string expected_title =
1044 "Referrer is " + instant_url().GetWithEmptyPath().spec(); 1047 "Referrer is " + instant_url().GetWithEmptyPath().spec();
1045 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); 1048 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle());
1046 } 1049 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698