OLD | NEW |
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/audio/audio_directive_list.h" | 5 #include "components/copresence/handlers/audio/audio_directive_list.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "components/copresence/test/audio_test_support.h" | 10 #include "components/copresence/test/audio_test_support.h" |
11 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace copresence { | 14 namespace copresence { |
15 | 15 |
16 class AudioDirectiveListTest : public testing::Test { | 16 class AudioDirectiveListTest : public testing::Test { |
17 public: | 17 public: |
18 AudioDirectiveListTest() | 18 AudioDirectiveListTest() |
19 : directive_list_(new AudioDirectiveList( | 19 : directive_list_(new AudioDirectiveList( |
20 base::Bind(&AudioDirectiveListTest::EncodeToken, | 20 base::Bind(&AudioDirectiveListTest::EncodeToken, |
21 base::Unretained(this)), | 21 base::Unretained(this)), |
22 base::Bind(&base::DoNothing), | 22 base::Bind(&base::DoNothing), |
23 false)) {} | 23 false)) {} |
24 | 24 |
25 virtual ~AudioDirectiveListTest() {} | 25 virtual ~AudioDirectiveListTest() {} |
26 | 26 |
27 protected: | 27 protected: |
28 void EncodeToken(const std::string& token, | 28 void EncodeToken(const std::string& token, |
29 bool /* audible */, | 29 bool audible, |
30 const AudioDirectiveList::SamplesCallback& callback) { | 30 const AudioDirectiveList::SamplesCallback& callback) { |
31 callback.Run(token, CreateRandomAudioRefCounted(0x1337, 1, 0x7331)); | 31 callback.Run( |
| 32 token, audible, CreateRandomAudioRefCounted(0x1337, 1, 0x7331)); |
32 } | 33 } |
33 | 34 |
34 base::MessageLoop message_loop_; | 35 base::MessageLoop message_loop_; |
35 scoped_ptr<AudioDirectiveList> directive_list_; | 36 scoped_ptr<AudioDirectiveList> directive_list_; |
36 }; | 37 }; |
37 | 38 |
38 // TODO(rkc): Find and fix the memory leak here. | 39 // TODO(rkc): Find and fix the memory leak here. |
39 #define MAYBE_Basic DISABLED_Basic | 40 #define MAYBE_Basic DISABLED_Basic |
40 | 41 |
41 TEST_F(AudioDirectiveListTest, MAYBE_Basic) { | 42 TEST_F(AudioDirectiveListTest, MAYBE_Basic) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 directive_list_->AddReceiveDirective("op_id3", kLargeTtl); | 82 directive_list_->AddReceiveDirective("op_id3", kLargeTtl); |
82 directive_list_->AddReceiveDirective("op_id7", kLargeTtl); | 83 directive_list_->AddReceiveDirective("op_id7", kLargeTtl); |
83 | 84 |
84 // Should keep getting the directive till it expires or we add a newer one. | 85 // Should keep getting the directive till it expires or we add a newer one. |
85 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); | 86 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); |
86 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); | 87 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); |
87 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); | 88 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); |
88 } | 89 } |
89 | 90 |
90 } // namespace copresence | 91 } // namespace copresence |
OLD | NEW |