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

Side by Side Diff: content/browser/speech/google_streaming_remote_engine_unittest.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 "content/browser/speech/google_streaming_remote_engine.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 #include <stdint.h> 8 #include <stdint.h>
7 9
10 #include <memory>
8 #include <queue> 11 #include <queue>
9 12
10 #include "base/big_endian.h" 13 #include "base/big_endian.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
13 #include "base/numerics/safe_conversions.h" 15 #include "base/numerics/safe_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
15 #include "base/sys_byteorder.h" 17 #include "base/sys_byteorder.h"
16 #include "content/browser/speech/audio_buffer.h" 18 #include "content/browser/speech/audio_buffer.h"
17 #include "content/browser/speech/google_streaming_remote_engine.h"
18 #include "content/browser/speech/proto/google_streaming_api.pb.h" 19 #include "content/browser/speech/proto/google_streaming_api.pb.h"
19 #include "content/public/common/speech_recognition_error.h" 20 #include "content/public/common/speech_recognition_error.h"
20 #include "content/public/common/speech_recognition_result.h" 21 #include "content/public/common/speech_recognition_result.h"
21 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
22 #include "net/url_request/test_url_fetcher_factory.h" 23 #include "net/url_request/test_url_fetcher_factory.h"
23 #include "net/url_request/url_request_context_getter.h" 24 #include "net/url_request/url_request_context_getter.h"
24 #include "net/url_request/url_request_status.h" 25 #include "net/url_request/url_request_status.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 27
27 using base::HostToNet32; 28 using base::HostToNet32;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void InjectDummyAudioChunk(); 88 void InjectDummyAudioChunk();
88 size_t UpstreamChunksUploadedFromLastCall(); 89 size_t UpstreamChunksUploadedFromLastCall();
89 std::string LastUpstreamChunkUploaded(); 90 std::string LastUpstreamChunkUploaded();
90 void ProvideMockProtoResultDownstream( 91 void ProvideMockProtoResultDownstream(
91 const proto::SpeechRecognitionEvent& result); 92 const proto::SpeechRecognitionEvent& result);
92 void ProvideMockResultDownstream(const SpeechRecognitionResult& result); 93 void ProvideMockResultDownstream(const SpeechRecognitionResult& result);
93 void ExpectResultsReceived(const SpeechRecognitionResults& result); 94 void ExpectResultsReceived(const SpeechRecognitionResults& result);
94 void ExpectFramedChunk(const std::string& chunk, uint32_t type); 95 void ExpectFramedChunk(const std::string& chunk, uint32_t type);
95 void CloseMockDownstream(DownstreamError error); 96 void CloseMockDownstream(DownstreamError error);
96 97
97 scoped_ptr<GoogleStreamingRemoteEngine> engine_under_test_; 98 std::unique_ptr<GoogleStreamingRemoteEngine> engine_under_test_;
98 TestURLFetcherFactory url_fetcher_factory_; 99 TestURLFetcherFactory url_fetcher_factory_;
99 size_t last_number_of_upstream_chunks_seen_; 100 size_t last_number_of_upstream_chunks_seen_;
100 base::MessageLoop message_loop_; 101 base::MessageLoop message_loop_;
101 std::string response_buffer_; 102 std::string response_buffer_;
102 SpeechRecognitionErrorCode error_; 103 SpeechRecognitionErrorCode error_;
103 int end_of_utterance_counter_; 104 int end_of_utterance_counter_;
104 std::queue<SpeechRecognitionResults> results_; 105 std::queue<SpeechRecognitionResults> results_;
105 }; 106 };
106 107
107 TEST_F(GoogleStreamingRemoteEngineTest, SingleDefinitiveResult) { 108 TEST_F(GoogleStreamingRemoteEngineTest, SingleDefinitiveResult) {
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 597
597 // Prepend 4 byte prefix length indication to the protobuf message as 598 // Prepend 4 byte prefix length indication to the protobuf message as
598 // envisaged by the google streaming recognition webservice protocol. 599 // envisaged by the google streaming recognition webservice protocol.
599 uint32_t prefix = HostToNet32(checked_cast<uint32_t>(msg_string.size())); 600 uint32_t prefix = HostToNet32(checked_cast<uint32_t>(msg_string.size()));
600 msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix)); 601 msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix));
601 602
602 return msg_string; 603 return msg_string;
603 } 604 }
604 605
605 } // namespace content 606 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/speech/google_streaming_remote_engine.h ('k') | content/browser/speech/speech_recognition_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698