OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" | 5 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/test/scoped_task_environment.h" |
8 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
9 #include "gpu/ipc/service/gpu_channel.h" | 10 #include "gpu/ipc/service/gpu_channel.h" |
10 #include "media/gpu/ipc/common/media_messages.h" | 11 #include "media/gpu/ipc/common/media_messages.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 using testing::_; | 15 using testing::_; |
15 using testing::SaveArg; | 16 using testing::SaveArg; |
16 using testing::InvokeWithoutArgs; | 17 using testing::InvokeWithoutArgs; |
17 using testing::Return; | 18 using testing::Return; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 74 |
74 protected: | 75 protected: |
75 base::Thread io_thread_; | 76 base::Thread io_thread_; |
76 MockFilteredSender gpu_channel_; | 77 MockFilteredSender gpu_channel_; |
77 std::unique_ptr<GpuJpegDecodeAccelerator> system_under_test_; | 78 std::unique_ptr<GpuJpegDecodeAccelerator> system_under_test_; |
78 base::SharedMemory output_frame_memory_; | 79 base::SharedMemory output_frame_memory_; |
79 | 80 |
80 private: | 81 private: |
81 // This is required to allow base::ThreadTaskRunnerHandle::Get() from the | 82 // This is required to allow base::ThreadTaskRunnerHandle::Get() from the |
82 // test execution thread. | 83 // test execution thread. |
83 base::MessageLoop message_loop_; | 84 base::test::ScopedTaskEnvironment scoped_task_environment_; |
84 }; | 85 }; |
85 | 86 |
86 // Tests that the communication for decoding a frame between the caller of | 87 // Tests that the communication for decoding a frame between the caller of |
87 // IPC:MessageFilter and the media::JpegDecodeAccelerator works as expected. | 88 // IPC:MessageFilter and the media::JpegDecodeAccelerator works as expected. |
88 TEST_F(GpuJpegDecodeAcceleratorTest, DecodeFrameCallArrivesAtDecoder) { | 89 TEST_F(GpuJpegDecodeAcceleratorTest, DecodeFrameCallArrivesAtDecoder) { |
89 static const int32_t kArbitraryRouteId = 123; | 90 static const int32_t kArbitraryRouteId = 123; |
90 auto io_task_runner = io_thread_.task_runner(); | 91 auto io_task_runner = io_thread_.task_runner(); |
91 auto main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 92 auto main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
92 auto decoder = base::MakeUnique<MockJpegDecodeAccelerator>(); | 93 auto decoder = base::MakeUnique<MockJpegDecodeAccelerator>(); |
93 auto* decoder_ptr = decoder.get(); | 94 auto* decoder_ptr = decoder.get(); |
(...skipping 27 matching lines...) Expand all Loading... |
121 EXPECT_CALL(*decoder_ptr, Decode(_, _)); | 122 EXPECT_CALL(*decoder_ptr, Decode(_, _)); |
122 io_task_runner->PostTaskAndReply( | 123 io_task_runner->PostTaskAndReply( |
123 FROM_HERE, | 124 FROM_HERE, |
124 base::Bind(&GpuJpegDecodeAcceleratorTest::SendStubFrame, | 125 base::Bind(&GpuJpegDecodeAcceleratorTest::SendStubFrame, |
125 base::Unretained(this), message_filter, kArbitraryRouteId), | 126 base::Unretained(this), message_filter, kArbitraryRouteId), |
126 run_loop2.QuitClosure()); | 127 run_loop2.QuitClosure()); |
127 run_loop2.Run(); | 128 run_loop2.Run(); |
128 } | 129 } |
129 | 130 |
130 } // namespace media | 131 } // namespace media |
OLD | NEW |