| 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_handler.h" | 5 #include "components/copresence/handlers/audio/audio_directive_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "components/copresence/test/audio_test_support.h" | 9 #include "components/copresence/test/audio_test_support.h" |
| 10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // This order is important. We want the message loop to get created before | 70 // This order is important. We want the message loop to get created before |
| 71 // our the audio directive handler since the directive list ctor (invoked | 71 // our the audio directive handler since the directive list ctor (invoked |
| 72 // from the directive handler ctor) will post tasks. | 72 // from the directive handler ctor) will post tasks. |
| 73 base::MessageLoop message_loop_; | 73 base::MessageLoop message_loop_; |
| 74 scoped_ptr<MockAudioDirectiveHandler> directive_handler_; | 74 scoped_ptr<MockAudioDirectiveHandler> directive_handler_; |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerTest); | 77 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerTest); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 // TODO(rkc): Find and fix the memory leak here. | 80 // TODO(rkc): This test is broken, possibly due to the changes for audible. |
| 81 #define MAYBE_Basic DISABLED_Basic | 81 TEST_F(AudioDirectiveHandlerTest, DISABLED_Basic) { |
| 82 | |
| 83 TEST_F(AudioDirectiveHandlerTest, MAYBE_Basic) { | |
| 84 const base::TimeDelta kSmallTtl = base::TimeDelta::FromMilliseconds(0x1337); | 82 const base::TimeDelta kSmallTtl = base::TimeDelta::FromMilliseconds(0x1337); |
| 85 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331); | 83 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331); |
| 86 | 84 |
| 87 // Expect to play and record instructions for 'less' than the TTL specified, | 85 // Expect to play and record instructions for 'less' than the TTL specified, |
| 88 // since by the time that the token would have gotten encoded, we would | 86 // since by the time that the token would have gotten encoded, we would |
| 89 // have (TTL - time_to_encode) left to play on that instruction. | 87 // have (TTL - time_to_encode) left to play on that instruction. |
| 90 EXPECT_CALL(*directive_handler_, PlayAudio(_, testing::Le(kLargeTtl))) | 88 EXPECT_CALL(*directive_handler_, PlayAudio(_, testing::Le(kLargeTtl))) |
| 91 .Times(3); | 89 .Times(3); |
| 92 directive_handler_->AddInstruction(CreateTransmitInstruction("token1"), | 90 directive_handler_->AddInstruction(CreateTransmitInstruction("token1"), |
| 93 kLargeTtl); | 91 kLargeTtl); |
| 94 directive_handler_->AddInstruction(CreateTransmitInstruction("token2"), | 92 directive_handler_->AddInstruction(CreateTransmitInstruction("token2"), |
| 95 kLargeTtl); | 93 kLargeTtl); |
| 96 directive_handler_->AddInstruction(CreateTransmitInstruction("token3"), | 94 directive_handler_->AddInstruction(CreateTransmitInstruction("token3"), |
| 97 kSmallTtl); | 95 kSmallTtl); |
| 98 | 96 |
| 99 EXPECT_CALL(*directive_handler_, RecordAudio(Le(kLargeTtl))).Times(3); | 97 EXPECT_CALL(*directive_handler_, RecordAudio(Le(kLargeTtl))).Times(3); |
| 100 directive_handler_->AddInstruction(CreateReceiveInstruction(), kLargeTtl); | 98 directive_handler_->AddInstruction(CreateReceiveInstruction(), kLargeTtl); |
| 101 directive_handler_->AddInstruction(CreateReceiveInstruction(), kSmallTtl); | 99 directive_handler_->AddInstruction(CreateReceiveInstruction(), kSmallTtl); |
| 102 directive_handler_->AddInstruction(CreateReceiveInstruction(), kLargeTtl); | 100 directive_handler_->AddInstruction(CreateReceiveInstruction(), kLargeTtl); |
| 103 } | 101 } |
| 104 | 102 |
| 105 // TODO(rkc): When we are keeping track of which token we're currently playing, | 103 // TODO(rkc): When we are keeping track of which token we're currently playing, |
| 106 // add tests to make sure we don't replay if we get a token with a lower ttl | 104 // add tests to make sure we don't replay if we get a token with a lower ttl |
| 107 // than the current active. | 105 // than the current active. |
| 108 | 106 |
| 109 } // namespace copresence | 107 } // namespace copresence |
| OLD | NEW |