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

Side by Side Diff: content/browser/speech/endpointer/endpointer_unittest.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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/audio_buffer.h" 5 #include "content/browser/speech/audio_buffer.h"
6 #include "content/browser/speech/endpointer/endpointer.h" 6 #include "content/browser/speech/endpointer/endpointer.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace { 9 namespace {
10 const int kFrameRate = 50; // 20 ms long frames for AMR encoding. 10 const int kFrameRate = 50; // 20 ms long frames for AMR encoding.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 // Test endpointer wrapper class. 113 // Test endpointer wrapper class.
114 class EndpointerFrameProcessor : public FrameProcessor { 114 class EndpointerFrameProcessor : public FrameProcessor {
115 public: 115 public:
116 explicit EndpointerFrameProcessor(Endpointer* endpointer) 116 explicit EndpointerFrameProcessor(Endpointer* endpointer)
117 : endpointer_(endpointer) {} 117 : endpointer_(endpointer) {}
118 118
119 EpStatus ProcessFrame(int64 time, int16* samples, int frame_size) { 119 EpStatus ProcessFrame(int64 time, int16* samples, int frame_size) {
120 scoped_refptr<AudioChunk> frame( 120 scoped_refptr<AudioChunk> frame(
121 new AudioChunk(reinterpret_cast<uint8*>(samples), kFrameSize * 2, 2)); 121 new AudioChunk(reinterpret_cast<uint8*>(samples), kFrameSize * 2, 2));
122 endpointer_->ProcessAudio(*frame, NULL); 122 endpointer_->ProcessAudio(*frame.get(), NULL);
123 int64 ep_time; 123 int64 ep_time;
124 return endpointer_->Status(&ep_time); 124 return endpointer_->Status(&ep_time);
125 } 125 }
126 126
127 private: 127 private:
128 Endpointer* endpointer_; 128 Endpointer* endpointer_;
129 }; 129 };
130 130
131 TEST(EndpointerTest, TestEmbeddedEndpointerEvents) { 131 TEST(EndpointerTest, TestEmbeddedEndpointerEvents) {
132 const int kSampleRate = 8000; // 8 k samples per second for AMR encoding. 132 const int kSampleRate = 8000; // 8 k samples per second for AMR encoding.
133 133
134 Endpointer endpointer(kSampleRate); 134 Endpointer endpointer(kSampleRate);
135 const int64 kMillisecondsPerMicrosecond = 1000; 135 const int64 kMillisecondsPerMicrosecond = 1000;
136 const int64 short_timeout = 300 * kMillisecondsPerMicrosecond; 136 const int64 short_timeout = 300 * kMillisecondsPerMicrosecond;
137 endpointer.set_speech_input_possibly_complete_silence_length(short_timeout); 137 endpointer.set_speech_input_possibly_complete_silence_length(short_timeout);
138 const int64 long_timeout = 500 * kMillisecondsPerMicrosecond; 138 const int64 long_timeout = 500 * kMillisecondsPerMicrosecond;
139 endpointer.set_speech_input_complete_silence_length(long_timeout); 139 endpointer.set_speech_input_complete_silence_length(long_timeout);
140 endpointer.StartSession(); 140 endpointer.StartSession();
141 141
142 EndpointerFrameProcessor frame_processor(&endpointer); 142 EndpointerFrameProcessor frame_processor(&endpointer);
143 RunEndpointerEventsTest(&frame_processor); 143 RunEndpointerEventsTest(&frame_processor);
144 144
145 endpointer.EndSession(); 145 endpointer.EndSession();
146 } 146 }
147 147
148 } // namespace content 148 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_instance_impl_unittest.cc ('k') | content/browser/speech/input_tag_speech_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698