| 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/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "gpu/ipc/service/gpu_channel.h" | 9 #include "gpu/ipc/service/gpu_channel.h" |
| 10 #include "media/gpu/ipc/common/media_messages.h" | 10 #include "media/gpu/ipc/common/media_messages.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 base::MessageLoop message_loop_; | 83 base::MessageLoop message_loop_; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 // Tests that the communication for decoding a frame between the caller of | 86 // Tests that the communication for decoding a frame between the caller of |
| 87 // IPC:MessageFilter and the media::JpegDecodeAccelerator works as expected. | 87 // IPC:MessageFilter and the media::JpegDecodeAccelerator works as expected. |
| 88 TEST_F(GpuJpegDecodeAcceleratorTest, DecodeFrameCallArrivesAtDecoder) { | 88 TEST_F(GpuJpegDecodeAcceleratorTest, DecodeFrameCallArrivesAtDecoder) { |
| 89 static const int32_t kArbitraryRouteId = 123; | 89 static const int32_t kArbitraryRouteId = 123; |
| 90 auto io_task_runner = io_thread_.task_runner(); | 90 auto io_task_runner = io_thread_.task_runner(); |
| 91 auto main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 91 auto main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 92 auto decoder = base::MakeUnique<MockJpegDecodeAccelerator>(); | 92 auto decoder = base::MakeUnique<MockJpegDecodeAccelerator>(); |
| 93 auto* decoder_ptr = decoder.get(); | 93 auto decoder_ptr = decoder.get(); |
| 94 ON_CALL(*decoder, Initialize(_)).WillByDefault(Return(true)); | 94 ON_CALL(*decoder, Initialize(_)).WillByDefault(Return(true)); |
| 95 | 95 |
| 96 IPC::MessageFilter* message_filter = nullptr; | 96 IPC::MessageFilter* message_filter = nullptr; |
| 97 EXPECT_CALL(*this, GetMockJpegDecodeAccelerator(_)) | 97 EXPECT_CALL(*this, GetMockJpegDecodeAccelerator(_)) |
| 98 .WillOnce(InvokeWithoutArgs([&decoder]() { return std::move(decoder); })); | 98 .WillOnce(InvokeWithoutArgs([&decoder]() { return std::move(decoder); })); |
| 99 EXPECT_CALL(gpu_channel_, AddFilter(_)).WillOnce(SaveArg<0>(&message_filter)); | 99 EXPECT_CALL(gpu_channel_, AddFilter(_)).WillOnce(SaveArg<0>(&message_filter)); |
| 100 base::RunLoop run_loop; | 100 base::RunLoop run_loop; |
| 101 auto response_cb = base::Bind( | 101 auto response_cb = base::Bind( |
| 102 [](base::RunLoop* run_loop, | 102 [](base::RunLoop* run_loop, |
| 103 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 103 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 121 EXPECT_CALL(*decoder_ptr, Decode(_, _)); | 121 EXPECT_CALL(*decoder_ptr, Decode(_, _)); |
| 122 io_task_runner->PostTaskAndReply( | 122 io_task_runner->PostTaskAndReply( |
| 123 FROM_HERE, | 123 FROM_HERE, |
| 124 base::Bind(&GpuJpegDecodeAcceleratorTest::SendStubFrame, | 124 base::Bind(&GpuJpegDecodeAcceleratorTest::SendStubFrame, |
| 125 base::Unretained(this), message_filter, kArbitraryRouteId), | 125 base::Unretained(this), message_filter, kArbitraryRouteId), |
| 126 run_loop2.QuitClosure()); | 126 run_loop2.QuitClosure()); |
| 127 run_loop2.Run(); | 127 run_loop2.Run(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace media | 130 } // namespace media |
| OLD | NEW |