| 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 "chrome/browser/spellchecker/spelling_service_client.h" | 5 #include "chrome/browser/spellchecker/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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/common/spellcheck_result.h" | |
| 21 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 22 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 22 #include "components/spellcheck/common/spellcheck_result.h" |
| 23 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
| 25 #include "net/url_request/test_url_fetcher_factory.h" | 25 #include "net/url_request/test_url_fetcher_factory.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // A mock URL fetcher used in the TestingSpellingServiceClient class. This class | 30 // A mock URL fetcher used in the TestingSpellingServiceClient class. This class |
| 31 // verifies JSON-RPC requests when the SpellingServiceClient class sends them to | 31 // verifies JSON-RPC requests when the SpellingServiceClient class sends them to |
| 32 // the Spelling service. This class also verifies the SpellingServiceClient | 32 // the Spelling service. This class also verifies the SpellingServiceClient |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); | 416 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 | 419 |
| 420 // Verify that an error in JSON response from spelling service will result in | 420 // Verify that an error in JSON response from spelling service will result in |
| 421 // ParseResponse returning false. | 421 // ParseResponse returning false. |
| 422 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { | 422 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { |
| 423 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); | 423 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); |
| 424 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); | 424 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); |
| 425 } | 425 } |
| OLD | NEW |