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

Side by Side Diff: components/copresence/handlers/directive_handler_unittest.cc

Issue 704923002: Add polling and audio check to copresence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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 "components/copresence/handlers/directive_handler.h" 5 #include "components/copresence/handlers/directive_handler.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "components/copresence/handlers/audio/audio_directive_handler.h" 8 #include "components/copresence/handlers/audio/audio_directive_handler.h"
9 #include "components/copresence/proto/data.pb.h" 9 #include "components/copresence/proto/data.pb.h"
10 #include "components/copresence/test/stub_whispernet_client.h" 10 #include "components/copresence/test/stub_whispernet_client.h"
(...skipping 17 matching lines...) Expand all
28 instruction->set_medium(AUDIO_ULTRASOUND_PASSBAND); 28 instruction->set_medium(AUDIO_ULTRASOUND_PASSBAND);
29 directive.set_allocated_token_instruction(instruction); 29 directive.set_allocated_token_instruction(instruction);
30 30
31 return directive; 31 return directive;
32 } 32 }
33 33
34 class FakeAudioDirectiveHandler final : public AudioDirectiveHandler { 34 class FakeAudioDirectiveHandler final : public AudioDirectiveHandler {
35 public: 35 public:
36 FakeAudioDirectiveHandler() {} 36 FakeAudioDirectiveHandler() {}
37 37
38 void Initialize( 38 void Initialize(WhispernetClient* /* whispernet_client */,
39 const AudioManager::DecodeSamplesCallback& /* decode_cb */, 39 const TokensCallback& /* tokens_cb */) override {}
40 const AudioManager::EncodeTokenCallback& /* encode_cb */) override {}
41 40
42 void AddInstruction(const TokenInstruction& instruction, 41 void AddInstruction(const TokenInstruction& instruction,
43 const std::string& /* op_id */, 42 const std::string& /* op_id */,
44 base::TimeDelta /* ttl_ms */) override { 43 base::TimeDelta /* ttl_ms */) override {
45 added_tokens_.push_back(instruction.token_id()); 44 added_tokens_.push_back(instruction.token_id());
46 } 45 }
47 46
48 void RemoveInstructions(const std::string& op_id) override { 47 void RemoveInstructions(const std::string& op_id) override {
49 removed_operations_.push_back(op_id); 48 removed_operations_.push_back(op_id);
50 } 49 }
51 50
52 const std::string PlayingToken(AudioType /* type */) const override { 51 const std::string PlayingToken(AudioType /* type */) const override {
53 NOTREACHED(); 52 NOTREACHED();
54 return ""; 53 return "";
55 } 54 }
56 55
56 bool IsPlayingTokenHeard(AudioType /* type */) const override {
57 NOTREACHED();
58 return false;
59 }
60
57 const std::vector<std::string>& added_tokens() const { 61 const std::vector<std::string>& added_tokens() const {
58 return added_tokens_; 62 return added_tokens_;
59 } 63 }
60 64
61 const std::vector<std::string>& removed_operations() const { 65 const std::vector<std::string>& removed_operations() const {
62 return removed_operations_; 66 return removed_operations_;
63 } 67 }
64 68
65 private: 69 private:
66 std::vector<std::string> added_tokens_; 70 std::vector<std::string> added_tokens_;
(...skipping 16 matching lines...) Expand all
83 87
84 TEST_F(DirectiveHandlerTest, Queuing) { 88 TEST_F(DirectiveHandlerTest, Queuing) {
85 directive_handler_.AddDirective(CreateDirective("id 1", "", "token 1")); 89 directive_handler_.AddDirective(CreateDirective("id 1", "", "token 1"));
86 directive_handler_.AddDirective(CreateDirective("", "id 1", "token 2")); 90 directive_handler_.AddDirective(CreateDirective("", "id 1", "token 2"));
87 directive_handler_.AddDirective(CreateDirective("id 2", "", "token 3")); 91 directive_handler_.AddDirective(CreateDirective("id 2", "", "token 3"));
88 directive_handler_.RemoveDirectives("id 1"); 92 directive_handler_.RemoveDirectives("id 1");
89 93
90 EXPECT_THAT(audio_handler_->added_tokens(), IsEmpty()); 94 EXPECT_THAT(audio_handler_->added_tokens(), IsEmpty());
91 EXPECT_THAT(audio_handler_->removed_operations(), IsEmpty()); 95 EXPECT_THAT(audio_handler_->removed_operations(), IsEmpty());
92 96
93 directive_handler_.Start(whispernet_client_.get()); 97 directive_handler_.Start(whispernet_client_.get(), TokensCallback());
94 directive_handler_.RemoveDirectives("id 3"); 98 directive_handler_.RemoveDirectives("id 3");
95 99
96 EXPECT_THAT(audio_handler_->added_tokens(), ElementsAre("token 3")); 100 EXPECT_THAT(audio_handler_->added_tokens(), ElementsAre("token 3"));
97 EXPECT_THAT(audio_handler_->removed_operations(), ElementsAre("id 3")); 101 EXPECT_THAT(audio_handler_->removed_operations(), ElementsAre("id 3"));
98 } 102 }
99 103
100 } // namespace copresence 104 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698