| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 159 } |
| 160 EXPECT_EQ(corrected_text_, text); | 160 EXPECT_EQ(corrected_text_, text); |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool ParseResponseSuccess(const std::string& data) { | 163 bool ParseResponseSuccess(const std::string& data) { |
| 164 std::vector<SpellCheckResult> results; | 164 std::vector<SpellCheckResult> results; |
| 165 return ParseResponse(data, &results); | 165 return ParseResponse(data, &results); |
| 166 } | 166 } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 net::URLFetcher* CreateURLFetcher(const GURL& url) override { | 169 scoped_ptr<net::URLFetcher> CreateURLFetcher(const GURL& url) override { |
| 170 EXPECT_EQ("https://www.googleapis.com/rpc", url.spec()); | 170 EXPECT_EQ("https://www.googleapis.com/rpc", url.spec()); |
| 171 fetcher_ = new TestSpellingURLFetcher(0, url, this, | 171 fetcher_ = new TestSpellingURLFetcher(0, url, this, |
| 172 request_type_, request_text_, | 172 request_type_, request_text_, |
| 173 request_language_, | 173 request_language_, |
| 174 response_status_, response_data_); | 174 response_status_, response_data_); |
| 175 return fetcher_; | 175 return scoped_ptr<net::URLFetcher>(fetcher_); |
| 176 } | 176 } |
| 177 | 177 |
| 178 int request_type_; | 178 int request_type_; |
| 179 std::string request_text_; | 179 std::string request_text_; |
| 180 std::string request_language_; | 180 std::string request_language_; |
| 181 int response_status_; | 181 int response_status_; |
| 182 std::string response_data_; | 182 std::string response_data_; |
| 183 bool success_; | 183 bool success_; |
| 184 base::string16 corrected_text_; | 184 base::string16 corrected_text_; |
| 185 TestSpellingURLFetcher* fetcher_; // weak | 185 TestSpellingURLFetcher* fetcher_; // weak |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 } | 375 } |
| 376 #endif // !defined(OS_MACOSX) | 376 #endif // !defined(OS_MACOSX) |
| 377 } | 377 } |
| 378 | 378 |
| 379 // Verify that an error in JSON response from spelling service will result in | 379 // Verify that an error in JSON response from spelling service will result in |
| 380 // ParseResponse returning false. | 380 // ParseResponse returning false. |
| 381 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { | 381 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { |
| 382 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); | 382 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); |
| 383 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); | 383 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); |
| 384 } | 384 } |
| OLD | NEW |