| OLD | NEW |
| 1 // Copyright (c) 2011 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/speech_recognition_request.h" | 7 #include "content/browser/speech/speech_recognition_request.h" |
| 8 #include "content/public/common/speech_input_result.h" | 8 #include "content/public/common/speech_recognition_traits.h" |
| 9 #include "content/test/test_url_fetcher_factory.h" | 9 #include "content/test/test_url_fetcher_factory.h" |
| 10 #include "net/url_request/url_request_context_getter.h" | 10 #include "net/url_request/url_request_context_getter.h" |
| 11 #include "net/url_request/url_request_status.h" | 11 #include "net/url_request/url_request_status.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace speech_input { | 14 namespace speech { |
| 15 | 15 |
| 16 class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate, | 16 class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate, |
| 17 public testing::Test { | 17 public testing::Test { |
| 18 public: | 18 public: |
| 19 SpeechRecognitionRequestTest() { } | 19 SpeechRecognitionRequestTest() { } |
| 20 | 20 |
| 21 // Creates a speech recognition request and invokes it's URL fetcher delegate | 21 // Creates a speech recognition request and invokes it's URL fetcher delegate |
| 22 // with the given test data. | 22 // with the given test data. |
| 23 void CreateAndTestRequest(bool success, const std::string& http_response); | 23 void CreateAndTestRequest(bool success, const std::string& http_response); |
| 24 | 24 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NETWORK); | 97 EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NETWORK); |
| 98 EXPECT_EQ(0U, result_.hypotheses.size()); | 98 EXPECT_EQ(0U, result_.hypotheses.size()); |
| 99 | 99 |
| 100 // Malformed JSON case. | 100 // Malformed JSON case. |
| 101 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" | 101 CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" |
| 102 "[{\"unknownkey\":\"hello\"}]}"); | 102 "[{\"unknownkey\":\"hello\"}]}"); |
| 103 EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NETWORK); | 103 EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NETWORK); |
| 104 EXPECT_EQ(0U, result_.hypotheses.size()); | 104 EXPECT_EQ(0U, result_.hypotheses.size()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace speech_input | 107 } // namespace speech |
| OLD | NEW |