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 <queue> | 5 #include <queue> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 GoogleStreamingRemoteEngineTest() | 36 GoogleStreamingRemoteEngineTest() |
37 : last_number_of_upstream_chunks_seen_(0U), | 37 : last_number_of_upstream_chunks_seen_(0U), |
38 error_(SPEECH_RECOGNITION_ERROR_NONE) { } | 38 error_(SPEECH_RECOGNITION_ERROR_NONE) { } |
39 | 39 |
40 // Creates a speech recognition request and invokes its URL fetcher delegate | 40 // Creates a speech recognition request and invokes its URL fetcher delegate |
41 // with the given test data. | 41 // with the given test data. |
42 void CreateAndTestRequest(bool success, const std::string& http_response); | 42 void CreateAndTestRequest(bool success, const std::string& http_response); |
43 | 43 |
44 // SpeechRecognitionRequestDelegate methods. | 44 // SpeechRecognitionRequestDelegate methods. |
45 virtual void OnSpeechRecognitionEngineResults( | 45 virtual void OnSpeechRecognitionEngineResults( |
46 const SpeechRecognitionResults& results) OVERRIDE { | 46 const SpeechRecognitionResults& results) override { |
47 results_.push(results); | 47 results_.push(results); |
48 } | 48 } |
49 virtual void OnSpeechRecognitionEngineError( | 49 virtual void OnSpeechRecognitionEngineError( |
50 const SpeechRecognitionError& error) OVERRIDE { | 50 const SpeechRecognitionError& error) override { |
51 error_ = error.code; | 51 error_ = error.code; |
52 } | 52 } |
53 | 53 |
54 // testing::Test methods. | 54 // testing::Test methods. |
55 virtual void SetUp() OVERRIDE; | 55 virtual void SetUp() override; |
56 virtual void TearDown() OVERRIDE; | 56 virtual void TearDown() override; |
57 | 57 |
58 protected: | 58 protected: |
59 enum DownstreamError { | 59 enum DownstreamError { |
60 DOWNSTREAM_ERROR_NONE, | 60 DOWNSTREAM_ERROR_NONE, |
61 DOWNSTREAM_ERROR_HTTP500, | 61 DOWNSTREAM_ERROR_HTTP500, |
62 DOWNSTREAM_ERROR_NETWORK, | 62 DOWNSTREAM_ERROR_NETWORK, |
63 DOWNSTREAM_ERROR_WEBSERVICE_NO_MATCH | 63 DOWNSTREAM_ERROR_WEBSERVICE_NO_MATCH |
64 }; | 64 }; |
65 static bool ResultsAreEqual(const SpeechRecognitionResults& a, | 65 static bool ResultsAreEqual(const SpeechRecognitionResults& a, |
66 const SpeechRecognitionResults& b); | 66 const SpeechRecognitionResults& b); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 490 |
491 // Prepend 4 byte prefix length indication to the protobuf message as | 491 // Prepend 4 byte prefix length indication to the protobuf message as |
492 // envisaged by the google streaming recognition webservice protocol. | 492 // envisaged by the google streaming recognition webservice protocol. |
493 uint32 prefix = HostToNet32(checked_cast<uint32>(msg_string.size())); | 493 uint32 prefix = HostToNet32(checked_cast<uint32>(msg_string.size())); |
494 msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix)); | 494 msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix)); |
495 | 495 |
496 return msg_string; | 496 return msg_string; |
497 } | 497 } |
498 | 498 |
499 } // namespace content | 499 } // namespace content |
OLD | NEW |