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

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

Issue 10581012: Move test_url_fetcher_factory.* from content/ to net/url_request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove export annotations Created 8 years, 6 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 | Annotate | Revision Log
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/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/spellchecker/spelling_service_client.h" 14 #include "chrome/browser/spellchecker/spelling_service_client.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "chrome/common/spellcheck_result.h" 16 #include "chrome/common/spellcheck_result.h"
17 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "content/public/test/test_url_fetcher_factory.h"
19 #include "net/base/load_flags.h" 18 #include "net/base/load_flags.h"
19 #include "net/url_request/test_url_fetcher_factory.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 namespace { 22 namespace {
23 23
24 // A mock URL fetcher used in the TestingSpellingServiceClient class. This class 24 // A mock URL fetcher used in the TestingSpellingServiceClient class. This class
25 // verifies JSON-RPC requests when the SpellingServiceClient class sends them to 25 // verifies JSON-RPC requests when the SpellingServiceClient class sends them to
26 // the Spelling service. This class also verifies the SpellingServiceClient 26 // the Spelling service. This class also verifies the SpellingServiceClient
27 // class does not either send cookies to the Spelling service or accept cookies 27 // class does not either send cookies to the Spelling service or accept cookies
28 // from it. 28 // from it.
29 class TestSpellingURLFetcher : public TestURLFetcher { 29 class TestSpellingURLFetcher : public net::TestURLFetcher {
30 public: 30 public:
31 TestSpellingURLFetcher(int id, 31 TestSpellingURLFetcher(int id,
32 const GURL& url, 32 const GURL& url,
33 net::URLFetcherDelegate* d, 33 net::URLFetcherDelegate* d,
34 int version, 34 int version,
35 const std::string& text, 35 const std::string& text,
36 int status, 36 int status,
37 const std::string& response) 37 const std::string& response)
38 : TestURLFetcher(0, url, d), 38 : net::TestURLFetcher(0, url, d),
39 version_(base::StringPrintf("v%d", version)), 39 version_(base::StringPrintf("v%d", version)),
40 text_(text) { 40 text_(text) {
41 set_response_code(status); 41 set_response_code(status);
42 SetResponseString(response); 42 SetResponseString(response);
43 } 43 }
44 virtual ~TestSpellingURLFetcher() { 44 virtual ~TestSpellingURLFetcher() {
45 } 45 }
46 46
47 virtual void SetUploadData(const std::string& upload_content_type, 47 virtual void SetUploadData(const std::string& upload_content_type,
48 const std::string& upload_content) OVERRIDE { 48 const std::string& upload_content) OVERRIDE {
(...skipping 15 matching lines...) Expand all
64 std::string text; 64 std::string text;
65 EXPECT_TRUE(value->GetString("params.text", &text)); 65 EXPECT_TRUE(value->GetString("params.text", &text));
66 EXPECT_EQ(text_, text); 66 EXPECT_EQ(text_, text);
67 std::string language; 67 std::string language;
68 EXPECT_TRUE(value->GetString("params.language", &language)); 68 EXPECT_TRUE(value->GetString("params.language", &language));
69 EXPECT_EQ("en", language); 69 EXPECT_EQ("en", language);
70 std::string country; 70 std::string country;
71 EXPECT_TRUE(value->GetString("params.origin_country", &country)); 71 EXPECT_TRUE(value->GetString("params.origin_country", &country));
72 EXPECT_EQ("USA", country); 72 EXPECT_EQ("USA", country);
73 73
74 TestURLFetcher::SetUploadData(upload_content_type, upload_content); 74 net::TestURLFetcher::SetUploadData(upload_content_type, upload_content);
75 } 75 }
76 76
77 virtual void Start() OVERRIDE { 77 virtual void Start() OVERRIDE {
78 // Verify that this client does not either send cookies to the Spelling 78 // Verify that this client does not either send cookies to the Spelling
79 // service or accept cookies from it. 79 // service or accept cookies from it.
80 EXPECT_EQ(net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES, 80 EXPECT_EQ(net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES,
81 GetLoadFlags()); 81 GetLoadFlags());
82 } 82 }
83 83
84 private: 84 private:
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 "it-IT", "lt-LT", "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT", 320 "it-IT", "lt-LT", "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT",
321 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR", 321 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR",
322 "uk-UA", "vi-VN", 322 "uk-UA", "vi-VN",
323 }; 323 };
324 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) { 324 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) {
325 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]); 325 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]);
326 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest)); 326 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest));
327 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); 327 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck));
328 } 328 }
329 } 329 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/ubertoken_fetcher_unittest.cc ('k') | chrome/browser/sync/glue/http_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698