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

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

Issue 820673004: json_schema_compiler: Use std::vector<char> for binary values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify_json_schema
Patch Set: Fix merge error. Created 5 years, 11 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 <queue> 5 #include <queue>
6 6
7 #include "base/big_endian.h" 7 #include "base/big_endian.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 EndMockRecognition(); 326 EndMockRecognition();
327 327
328 // Since there was no final result, we get an empty "no match" result. 328 // Since there was no final result, we get an empty "no match" result.
329 SpeechRecognitionResults empty_result; 329 SpeechRecognitionResults empty_result;
330 ExpectResultsReceived(empty_result); 330 ExpectResultsReceived(empty_result);
331 ASSERT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 331 ASSERT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
332 ASSERT_EQ(0U, results_.size()); 332 ASSERT_EQ(0U, results_.size());
333 } 333 }
334 334
335 TEST_F(GoogleStreamingRemoteEngineTest, SendPreamble) { 335 TEST_F(GoogleStreamingRemoteEngineTest, SendPreamble) {
336 const int kPreambleLength = 100; 336 const size_t kPreambleLength = 100;
337 scoped_refptr<SpeechRecognitionSessionPreamble> preamble = 337 scoped_refptr<SpeechRecognitionSessionPreamble> preamble =
338 new SpeechRecognitionSessionPreamble(); 338 new SpeechRecognitionSessionPreamble();
339 preamble->sample_rate = 16000; 339 preamble->sample_rate = 16000;
340 preamble->sample_depth = 2; 340 preamble->sample_depth = 2;
341 preamble->sample_data = std::string(kPreambleLength, 0); 341 preamble->sample_data.assign(kPreambleLength, 0);
342 SpeechRecognitionEngine::Config config; 342 SpeechRecognitionEngine::Config config;
343 config.auth_token = "foo"; 343 config.auth_token = "foo";
344 config.auth_scope = "bar"; 344 config.auth_scope = "bar";
345 config.preamble = preamble; 345 config.preamble = preamble;
346 engine_under_test_->SetConfig(config); 346 engine_under_test_->SetConfig(config);
347 347
348 StartMockRecognition(); 348 StartMockRecognition();
349 ASSERT_TRUE(GetUpstreamFetcher()); 349 ASSERT_TRUE(GetUpstreamFetcher());
350 // First chunk uploaded should be the preamble. 350 // First chunk uploaded should be the preamble.
351 ASSERT_EQ(1U, UpstreamChunksUploadedFromLastCall()); 351 ASSERT_EQ(1U, UpstreamChunksUploadedFromLastCall());
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 563
564 // Prepend 4 byte prefix length indication to the protobuf message as 564 // Prepend 4 byte prefix length indication to the protobuf message as
565 // envisaged by the google streaming recognition webservice protocol. 565 // envisaged by the google streaming recognition webservice protocol.
566 uint32 prefix = HostToNet32(checked_cast<uint32>(msg_string.size())); 566 uint32 prefix = HostToNet32(checked_cast<uint32>(msg_string.size()));
567 msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix)); 567 msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix));
568 568
569 return msg_string; 569 return msg_string;
570 } 570 }
571 571
572 } // namespace content 572 } // namespace content
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_third_party_vpn_observer.h ('k') | content/public/browser/speech_recognition_session_preamble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698