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

Side by Side Diff: components/copresence/handlers/audio/audio_directive_handler_unittest.cc

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h>
6
5 #include <string> 7 #include <string>
6 #include <vector> 8 #include <vector>
7 9
8 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
11 #include "base/test/simple_test_tick_clock.h" 14 #include "base/test/simple_test_tick_clock.h"
12 #include "base/timer/mock_timer.h" 15 #include "base/timer/mock_timer.h"
13 #include "components/audio_modem/public/modem.h" 16 #include "components/audio_modem/public/modem.h"
14 #include "components/audio_modem/test/random_samples.h" 17 #include "components/audio_modem/test/random_samples.h"
15 #include "components/audio_modem/test/stub_modem.h" 18 #include "components/audio_modem/test/stub_modem.h"
16 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h" 19 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h"
17 #include "components/copresence/handlers/audio/tick_clock_ref_counted.h" 20 #include "components/copresence/handlers/audio/tick_clock_ref_counted.h"
18 #include "components/copresence/proto/data.pb.h" 21 #include "components/copresence/proto/data.pb.h"
19 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
20 23
21 using audio_modem::AUDIBLE; 24 using audio_modem::AUDIBLE;
22 using audio_modem::AudioType; 25 using audio_modem::AudioType;
23 using audio_modem::INAUDIBLE; 26 using audio_modem::INAUDIBLE;
24 using audio_modem::StubModem; 27 using audio_modem::StubModem;
25 28
26 namespace copresence { 29 namespace copresence {
27 30
28 namespace { 31 namespace {
29 32
30 const Directive CreateDirective(TokenInstructionType type, 33 const Directive CreateDirective(TokenInstructionType type,
31 bool audible, 34 bool audible,
32 int64 ttl) { 35 int64_t ttl) {
33 Directive directive; 36 Directive directive;
34 directive.mutable_token_instruction()->set_token_instruction_type(type); 37 directive.mutable_token_instruction()->set_token_instruction_type(type);
35 directive.mutable_token_instruction()->set_token_id("token"); 38 directive.mutable_token_instruction()->set_token_id("token");
36 directive.mutable_token_instruction()->set_medium(audible ? 39 directive.mutable_token_instruction()->set_medium(audible ?
37 AUDIO_AUDIBLE_DTMF : AUDIO_ULTRASOUND_PASSBAND); 40 AUDIO_AUDIBLE_DTMF : AUDIO_ULTRASOUND_PASSBAND);
38 directive.set_ttl_millis(ttl); 41 directive.set_ttl_millis(ttl);
39 return directive; 42 return directive;
40 } 43 }
41 44
42 } // namespace 45 } // namespace
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 85
83 private: 86 private:
84 void GetDirectiveUpdates(const std::vector<Directive>& current_directives) { 87 void GetDirectiveUpdates(const std::vector<Directive>& current_directives) {
85 current_directives_ = current_directives; 88 current_directives_ = current_directives;
86 } 89 }
87 90
88 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerTest); 91 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerTest);
89 }; 92 };
90 93
91 TEST_F(AudioDirectiveHandlerTest, Basic) { 94 TEST_F(AudioDirectiveHandlerTest, Basic) {
92 const int64 kTtl = 10; 95 const int64_t kTtl = 10;
93 directive_handler_->AddInstruction(CreateDirective(TRANSMIT, true, kTtl), 96 directive_handler_->AddInstruction(CreateDirective(TRANSMIT, true, kTtl),
94 "op_id1"); 97 "op_id1");
95 directive_handler_->AddInstruction(CreateDirective(TRANSMIT, false, kTtl), 98 directive_handler_->AddInstruction(CreateDirective(TRANSMIT, false, kTtl),
96 "op_id1"); 99 "op_id1");
97 directive_handler_->AddInstruction(CreateDirective(TRANSMIT, false, kTtl), 100 directive_handler_->AddInstruction(CreateDirective(TRANSMIT, false, kTtl),
98 "op_id2"); 101 "op_id2");
99 directive_handler_->AddInstruction(CreateDirective(RECEIVE, false, kTtl), 102 directive_handler_->AddInstruction(CreateDirective(RECEIVE, false, kTtl),
100 "op_id1"); 103 "op_id1");
101 directive_handler_->AddInstruction(CreateDirective(RECEIVE, true, kTtl), 104 directive_handler_->AddInstruction(CreateDirective(RECEIVE, true, kTtl),
102 "op_id2"); 105 "op_id2");
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Advance to +11ms. 169 // Advance to +11ms.
167 clock_ptr_->Advance(twoMs); 170 clock_ptr_->Advance(twoMs);
168 timer_ptr_->Fire(); 171 timer_ptr_->Fire();
169 EXPECT_FALSE(IsRecording(AUDIBLE)); 172 EXPECT_FALSE(IsRecording(AUDIBLE));
170 } 173 }
171 174
172 // TODO(rkc): Write more tests that check more convoluted sequences of 175 // TODO(rkc): Write more tests that check more convoluted sequences of
173 // transmits/receives. 176 // transmits/receives.
174 177
175 } // namespace copresence 178 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698