| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |