| 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/command_line.h" | 8 #include "base/command_line.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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 string16 text(UTF8ToUTF16(request_text_)); | 155 string16 text(UTF8ToUTF16(request_text_)); |
| 156 EXPECT_EQ(text, request_text); | 156 EXPECT_EQ(text, request_text); |
| 157 for (std::vector<SpellCheckResult>::const_iterator it = results.begin(); | 157 for (std::vector<SpellCheckResult>::const_iterator it = results.begin(); |
| 158 it != results.end(); ++it) { | 158 it != results.end(); ++it) { |
| 159 text.replace(it->location, it->length, it->replacement); | 159 text.replace(it->location, it->length, it->replacement); |
| 160 } | 160 } |
| 161 EXPECT_EQ(corrected_text_, text); | 161 EXPECT_EQ(corrected_text_, text); |
| 162 } | 162 } |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 virtual net::URLFetcher* CreateURLFetcher(const GURL& url) { | 165 virtual net::URLFetcher* CreateURLFetcher(const GURL& url) OVERRIDE { |
| 166 EXPECT_EQ("https://www.googleapis.com/rpc", url.spec()); | 166 EXPECT_EQ("https://www.googleapis.com/rpc", url.spec()); |
| 167 fetcher_ = new TestSpellingURLFetcher(0, url, this, | 167 fetcher_ = new TestSpellingURLFetcher(0, url, this, |
| 168 request_type_, request_text_, | 168 request_type_, request_text_, |
| 169 request_language_, | 169 request_language_, |
| 170 response_status_, response_data_); | 170 response_status_, response_data_); |
| 171 return fetcher_; | 171 return fetcher_; |
| 172 } | 172 } |
| 173 | 173 |
| 174 int request_type_; | 174 int request_type_; |
| 175 std::string request_text_; | 175 std::string request_text_; |
| 176 std::string request_language_; | 176 std::string request_language_; |
| 177 int response_status_; | 177 int response_status_; |
| 178 std::string response_data_; | 178 std::string response_data_; |
| 179 bool success_; | 179 bool success_; |
| 180 string16 corrected_text_; | 180 string16 corrected_text_; |
| 181 TestSpellingURLFetcher* fetcher_; // weak | 181 TestSpellingURLFetcher* fetcher_; // weak |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 // A test class used for testing the SpellingServiceClient class. This class | 184 // A test class used for testing the SpellingServiceClient class. This class |
| 185 // implements a callback function used by the SpellingServiceClient class to | 185 // implements a callback function used by the SpellingServiceClient class to |
| 186 // monitor the class calls the callback with expected results. | 186 // monitor the class calls the callback with expected results. |
| 187 class SpellingServiceClientTest : public testing::Test { | 187 class SpellingServiceClientTest : public testing::Test { |
| 188 public: | 188 public: |
| 189 SpellingServiceClientTest() {} | 189 SpellingServiceClientTest() {} |
| 190 virtual ~SpellingServiceClientTest() {} | 190 virtual ~SpellingServiceClientTest() {} |
| 191 | 191 |
| 192 void SetUp() OVERRIDE { | 192 virtual void SetUp() OVERRIDE { |
| 193 } | 193 } |
| 194 | 194 |
| 195 void OnTextCheckComplete(int tag, | 195 void OnTextCheckComplete(int tag, |
| 196 bool success, | 196 bool success, |
| 197 const string16& text, | 197 const string16& text, |
| 198 const std::vector<SpellCheckResult>& results) { | 198 const std::vector<SpellCheckResult>& results) { |
| 199 client_.VerifyResponse(success, text, results); | 199 client_.VerifyResponse(success, text, results); |
| 200 } | 200 } |
| 201 | 201 |
| 202 protected: | 202 protected: |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR", | 371 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR", |
| 372 "uk-UA", "vi-VN", | 372 "uk-UA", "vi-VN", |
| 373 #endif | 373 #endif |
| 374 }; | 374 }; |
| 375 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) { | 375 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) { |
| 376 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]); | 376 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]); |
| 377 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest)); | 377 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest)); |
| 378 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); | 378 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); |
| 379 } | 379 } |
| 380 } | 380 } |
| OLD | NEW |