| 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "content/browser/speech/audio_buffer.h" | 7 #include "content/browser/speech/audio_buffer.h" |
| 8 #include "content/browser/speech/google_one_shot_remote_engine.h" | 8 #include "content/browser/speech/google_one_shot_remote_engine.h" |
| 9 #include "content/public/common/speech_recognition_error.h" | 9 #include "content/public/common/speech_recognition_error.h" |
| 10 #include "content/public/common/speech_recognition_result.h" | 10 #include "content/public/common/speech_recognition_result.h" |
| 11 #include "net/url_request/test_url_fetcher_factory.h" | 11 #include "net/url_request/test_url_fetcher_factory.h" |
| 12 #include "net/url_request/url_request_context_getter.h" | 12 #include "net/url_request/url_request_context_getter.h" |
| 13 #include "net/url_request/url_request_status.h" | 13 #include "net/url_request/url_request_status.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace speech { | 16 namespace speech { |
| 17 | 17 // TODO(primiano): This file should be refactored in order to take advantage of |
| 18 // the recently introduced MockGoogleOneShotServer class and remove duplicate |
| 19 // code (i.e. all the URLFetcher/JSON related code in this file). |
| 18 class GoogleOneShotRemoteEngineTest | 20 class GoogleOneShotRemoteEngineTest |
| 19 : public SpeechRecognitionEngineDelegate, | 21 : public SpeechRecognitionEngineDelegate, |
| 20 public testing::Test { | 22 public testing::Test { |
| 21 public: | 23 public: |
| 22 GoogleOneShotRemoteEngineTest() | 24 GoogleOneShotRemoteEngineTest() |
| 23 : error_(content::SPEECH_RECOGNITION_ERROR_NONE) {} | 25 : error_(content::SPEECH_RECOGNITION_ERROR_NONE) {} |
| 24 | 26 |
| 25 // Creates a speech recognition request and invokes its URL fetcher delegate | 27 // Creates a speech recognition request and invokes its URL fetcher delegate |
| 26 // with the given test data. | 28 // with the given test data. |
| 27 void CreateAndTestRequest(bool success, const std::string& http_response); | 29 void CreateAndTestRequest(bool success, const std::string& http_response); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 EXPECT_EQ(0U, result_.hypotheses.size()); | 116 EXPECT_EQ(0U, result_.hypotheses.size()); |
| 115 | 117 |
| 116 // Malformed JSON case. | 118 // Malformed JSON case. |
| 117 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" | 119 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" |
| 118 "[{\"unknownkey\":\"hello\"}]}"); | 120 "[{\"unknownkey\":\"hello\"}]}"); |
| 119 EXPECT_EQ(error_, content::SPEECH_RECOGNITION_ERROR_NETWORK); | 121 EXPECT_EQ(error_, content::SPEECH_RECOGNITION_ERROR_NETWORK); |
| 120 EXPECT_EQ(0U, result_.hypotheses.size()); | 122 EXPECT_EQ(0U, result_.hypotheses.size()); |
| 121 } | 123 } |
| 122 | 124 |
| 123 } // namespace speech | 125 } // namespace speech |
| OLD | NEW |