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

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

Issue 629603002: replace OVERRIDE and FINAL with override and final in chrome/browser/[r-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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
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 <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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 version_(base::StringPrintf("v%d", version)), 42 version_(base::StringPrintf("v%d", version)),
43 language_(language.empty() ? std::string("en") : language), 43 language_(language.empty() ? std::string("en") : language),
44 text_(text) { 44 text_(text) {
45 set_response_code(status); 45 set_response_code(status);
46 SetResponseString(response); 46 SetResponseString(response);
47 } 47 }
48 virtual ~TestSpellingURLFetcher() { 48 virtual ~TestSpellingURLFetcher() {
49 } 49 }
50 50
51 virtual void SetUploadData(const std::string& upload_content_type, 51 virtual void SetUploadData(const std::string& upload_content_type,
52 const std::string& upload_content) OVERRIDE { 52 const std::string& upload_content) override {
53 // Verify the given content type is JSON. (The Spelling service returns an 53 // Verify the given content type is JSON. (The Spelling service returns an
54 // internal server error when this content type is not JSON.) 54 // internal server error when this content type is not JSON.)
55 EXPECT_EQ("application/json", upload_content_type); 55 EXPECT_EQ("application/json", upload_content_type);
56 56
57 // Parse the JSON to be sent to the service, and verify its parameters. 57 // Parse the JSON to be sent to the service, and verify its parameters.
58 scoped_ptr<base::DictionaryValue> value(static_cast<base::DictionaryValue*>( 58 scoped_ptr<base::DictionaryValue> value(static_cast<base::DictionaryValue*>(
59 base::JSONReader::Read(upload_content, 59 base::JSONReader::Read(upload_content,
60 base::JSON_ALLOW_TRAILING_COMMAS))); 60 base::JSON_ALLOW_TRAILING_COMMAS)));
61 ASSERT_TRUE(!!value.get()); 61 ASSERT_TRUE(!!value.get());
62 std::string method; 62 std::string method;
63 EXPECT_TRUE(value->GetString("method", &method)); 63 EXPECT_TRUE(value->GetString("method", &method));
64 EXPECT_EQ("spelling.check", method); 64 EXPECT_EQ("spelling.check", method);
65 std::string version; 65 std::string version;
66 EXPECT_TRUE(value->GetString("apiVersion", &version)); 66 EXPECT_TRUE(value->GetString("apiVersion", &version));
67 EXPECT_EQ(version_, version); 67 EXPECT_EQ(version_, version);
68 std::string text; 68 std::string text;
69 EXPECT_TRUE(value->GetString("params.text", &text)); 69 EXPECT_TRUE(value->GetString("params.text", &text));
70 EXPECT_EQ(text_, text); 70 EXPECT_EQ(text_, text);
71 std::string language; 71 std::string language;
72 EXPECT_TRUE(value->GetString("params.language", &language)); 72 EXPECT_TRUE(value->GetString("params.language", &language));
73 EXPECT_EQ(language_, language); 73 EXPECT_EQ(language_, language);
74 ASSERT_TRUE(GetExpectedCountry(language, &country_)); 74 ASSERT_TRUE(GetExpectedCountry(language, &country_));
75 std::string country; 75 std::string country;
76 EXPECT_TRUE(value->GetString("params.originCountry", &country)); 76 EXPECT_TRUE(value->GetString("params.originCountry", &country));
77 EXPECT_EQ(country_, country); 77 EXPECT_EQ(country_, country);
78 78
79 net::TestURLFetcher::SetUploadData(upload_content_type, upload_content); 79 net::TestURLFetcher::SetUploadData(upload_content_type, upload_content);
80 } 80 }
81 81
82 virtual void Start() OVERRIDE { 82 virtual void Start() override {
83 // Verify that this client does not either send cookies to the Spelling 83 // Verify that this client does not either send cookies to the Spelling
84 // service or accept cookies from it. 84 // service or accept cookies from it.
85 EXPECT_EQ(net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES, 85 EXPECT_EQ(net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES,
86 GetLoadFlags()); 86 GetLoadFlags());
87 } 87 }
88 88
89 private: 89 private:
90 bool GetExpectedCountry(const std::string& language, std::string* country) { 90 bool GetExpectedCountry(const std::string& language, std::string* country) {
91 static const struct { 91 static const struct {
92 const char* language; 92 const char* language;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 EXPECT_EQ(corrected_text_, text); 162 EXPECT_EQ(corrected_text_, text);
163 } 163 }
164 164
165 bool ParseResponseSuccess(const std::string& data) { 165 bool ParseResponseSuccess(const std::string& data) {
166 std::vector<SpellCheckResult> results; 166 std::vector<SpellCheckResult> results;
167 return ParseResponse(data, &results); 167 return ParseResponse(data, &results);
168 } 168 }
169 169
170 private: 170 private:
171 virtual net::URLFetcher* CreateURLFetcher(const GURL& url) OVERRIDE { 171 virtual net::URLFetcher* CreateURLFetcher(const GURL& url) override {
172 EXPECT_EQ("https://www.googleapis.com/rpc", url.spec()); 172 EXPECT_EQ("https://www.googleapis.com/rpc", url.spec());
173 fetcher_ = new TestSpellingURLFetcher(0, url, this, 173 fetcher_ = new TestSpellingURLFetcher(0, url, this,
174 request_type_, request_text_, 174 request_type_, request_text_,
175 request_language_, 175 request_language_,
176 response_status_, response_data_); 176 response_status_, response_data_);
177 return fetcher_; 177 return fetcher_;
178 } 178 }
179 179
180 int request_type_; 180 int request_type_;
181 std::string request_text_; 181 std::string request_text_;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); 379 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck));
380 } 380 }
381 } 381 }
382 382
383 // Verify that an error in JSON response from spelling service will result in 383 // Verify that an error in JSON response from spelling service will result in
384 // ParseResponse returning false. 384 // ParseResponse returning false.
385 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { 385 TEST_F(SpellingServiceClientTest, ResponseErrorTest) {
386 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); 386 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}"));
387 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); 387 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}"));
388 } 388 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spelling_service_client.h ('k') | chrome/browser/ssl/chrome_ssl_host_state_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698