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

Side by Side Diff: chrome/browser/spellchecker/spelling_service_client_unittest.cc

Issue 2421333002: Protobuf for Traffic Annotation and first use by a URLFetcher. (Closed)
Patch Set: More comments added. Created 3 years, 10 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
« no previous file with comments | « no previous file | components/spellcheck/browser/spelling_service_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/spellcheck/browser/spelling_service_client.h" 5 #include "components/spellcheck/browser/spelling_service_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 164 }
165 EXPECT_EQ(corrected_text_, text); 165 EXPECT_EQ(corrected_text_, text);
166 } 166 }
167 167
168 bool ParseResponseSuccess(const std::string& data) { 168 bool ParseResponseSuccess(const std::string& data) {
169 std::vector<SpellCheckResult> results; 169 std::vector<SpellCheckResult> results;
170 return ParseResponse(data, &results); 170 return ParseResponse(data, &results);
171 } 171 }
172 172
173 private: 173 private:
174 std::unique_ptr<net::URLFetcher> CreateURLFetcher(const GURL& url) override { 174 std::unique_ptr<net::URLFetcher> CreateURLFetcher(
175 const GURL& url,
176 net::NetworkTrafficAnnotationTag traffic_annotation) override {
175 EXPECT_EQ("https://www.googleapis.com/rpc", url.spec()); 177 EXPECT_EQ("https://www.googleapis.com/rpc", url.spec());
176 fetcher_ = new TestSpellingURLFetcher( 178 fetcher_ = new TestSpellingURLFetcher(
177 0, url, this, request_type_, sanitized_request_text_, request_language_, 179 0, url, this, request_type_, sanitized_request_text_, request_language_,
178 response_status_, response_data_); 180 response_status_, response_data_);
179 return std::unique_ptr<net::URLFetcher>(fetcher_); 181 return std::unique_ptr<net::URLFetcher>(fetcher_);
180 } 182 }
181 183
182 int request_type_; 184 int request_type_;
183 std::string sanitized_request_text_; 185 std::string sanitized_request_text_;
184 std::string request_language_; 186 std::string request_language_;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); 418 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck));
417 } 419 }
418 } 420 }
419 421
420 // Verify that an error in JSON response from spelling service will result in 422 // Verify that an error in JSON response from spelling service will result in
421 // ParseResponse returning false. 423 // ParseResponse returning false.
422 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { 424 TEST_F(SpellingServiceClientTest, ResponseErrorTest) {
423 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); 425 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}"));
424 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); 426 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}"));
425 } 427 }
OLDNEW
« no previous file with comments | « no previous file | components/spellcheck/browser/spelling_service_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698