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 "remoting/host/linux/audio_pipe_reader.h" | 5 #include "remoting/host/linux/audio_pipe_reader.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #include "base/files/file.h" | 13 #include "base/files/file.h" |
12 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
17 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace remoting { | 22 namespace remoting { |
22 | 23 |
23 class AudioPipeReaderTest : public testing::Test, | 24 class AudioPipeReaderTest : public testing::Test, |
24 public AudioPipeReader::StreamObserver { | 25 public AudioPipeReader::StreamObserver { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 68 } |
68 | 69 |
69 void WriteAndWait(const std::string& data) { | 70 void WriteAndWait(const std::string& data) { |
70 ASSERT_EQ(static_cast<int>(data.size()), | 71 ASSERT_EQ(static_cast<int>(data.size()), |
71 output_->WriteAtCurrentPos(data.data(), data.size())); | 72 output_->WriteAtCurrentPos(data.data(), data.size())); |
72 WaitForInput(data.size()); | 73 WaitForInput(data.size()); |
73 } | 74 } |
74 | 75 |
75 protected: | 76 protected: |
76 base::MessageLoop message_loop_; | 77 base::MessageLoop message_loop_; |
77 scoped_ptr<base::RunLoop> run_loop_; | 78 std::unique_ptr<base::RunLoop> run_loop_; |
78 scoped_ptr<base::Thread> audio_thread_; | 79 std::unique_ptr<base::Thread> audio_thread_; |
79 base::ScopedTempDir test_dir_; | 80 base::ScopedTempDir test_dir_; |
80 base::FilePath pipe_path_; | 81 base::FilePath pipe_path_; |
81 scoped_ptr<base::File> output_; | 82 std::unique_ptr<base::File> output_; |
82 | 83 |
83 scoped_refptr<AudioPipeReader> reader_; | 84 scoped_refptr<AudioPipeReader> reader_; |
84 | 85 |
85 std::string read_data_; | 86 std::string read_data_; |
86 int stop_at_position_; | 87 int stop_at_position_; |
87 | 88 |
88 DISALLOW_COPY_AND_ASSIGN(AudioPipeReaderTest); | 89 DISALLOW_COPY_AND_ASSIGN(AudioPipeReaderTest); |
89 }; | 90 }; |
90 | 91 |
91 // Verify that the reader can detect when the pipe is created and destroyed. | 92 // Verify that the reader can detect when the pipe is created and destroyed. |
(...skipping 20 matching lines...) Expand all Loading... |
112 | 113 |
113 base::TimeTicks start_time = base::TimeTicks::Now(); | 114 base::TimeTicks start_time = base::TimeTicks::Now(); |
114 ASSERT_NO_FATAL_FAILURE(WriteAndWait(test_data)); | 115 ASSERT_NO_FATAL_FAILURE(WriteAndWait(test_data)); |
115 base::TimeDelta time_passed = base::TimeTicks::Now() - start_time; | 116 base::TimeDelta time_passed = base::TimeTicks::Now() - start_time; |
116 | 117 |
117 EXPECT_EQ(test_data, read_data_); | 118 EXPECT_EQ(test_data, read_data_); |
118 EXPECT_GE(time_passed, base::TimeDelta::FromMilliseconds(500)); | 119 EXPECT_GE(time_passed, base::TimeDelta::FromMilliseconds(500)); |
119 } | 120 } |
120 | 121 |
121 } // namespace remoting | 122 } // namespace remoting |
OLD | NEW |