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/chromeos/aura_desktop_capturer.h" | 5 #include "remoting/host/chromeos/aura_screen_capturer.h" |
6 | 6 |
7 #include "cc/output/copy_output_result.h" | 7 #include "cc/output/copy_output_result.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
12 | 12 |
13 using testing::_; | 13 using testing::_; |
14 using testing::SaveArg; | 14 using testing::SaveArg; |
15 | 15 |
(...skipping 11 matching lines...) Expand all Loading... |
27 0x47, 0x2f, 0xdf, 0x6e, 0xed, 0x7b, 0xf3, 0xc3, 0x37, 0x20, 0xf2, 0x36, | 27 0x47, 0x2f, 0xdf, 0x6e, 0xed, 0x7b, 0xf3, 0xc3, 0x37, 0x20, 0xf2, 0x36, |
28 0x67, 0x6c, 0x36, 0xe1, 0xb4, 0x5e, 0xbe, 0x04, 0x85, 0xdb, 0x89, 0xa3, | 28 0x67, 0x6c, 0x36, 0xe1, 0xb4, 0x5e, 0xbe, 0x04, 0x85, 0xdb, 0x89, 0xa3, |
29 0xcd, 0xfd, 0xd2, 0x4b, 0xd6, 0x9f, 0x00, 0x00, 0x00, 0x40, 0x38, 0x35, | 29 0xcd, 0xfd, 0xd2, 0x4b, 0xd6, 0x9f, 0x00, 0x00, 0x00, 0x40, 0x38, 0x35, |
30 0x05, 0x75, 0x1d, 0x13, 0x6e, 0xb3, 0x6b, 0x1d, 0x29, 0xae, 0xd3, 0x43, | 30 0x05, 0x75, 0x1d, 0x13, 0x6e, 0xb3, 0x6b, 0x1d, 0x29, 0xae, 0xd3, 0x43, |
31 0xe6, 0x84, 0x8f, 0xa3, 0x9d, 0x65, 0x4e, 0x2f, 0x57, 0xe3, 0xf6, 0xe6, | 31 0xe6, 0x84, 0x8f, 0xa3, 0x9d, 0x65, 0x4e, 0x2f, 0x57, 0xe3, 0xf6, 0xe6, |
32 0x20, 0x3c, 0x00, 0xc6, 0xe1, 0x73, 0x34, 0xe2, 0x23, 0x99, 0xc4, 0xfa, | 32 0x20, 0x3c, 0x00, 0xc6, 0xe1, 0x73, 0x34, 0xe2, 0x23, 0x99, 0xc4, 0xfa, |
33 0x91, 0xc2, 0xd5, 0x97, 0xc1, 0x8b, 0xd0, 0x3c, 0x13, 0xba, 0xf0, 0xd7 | 33 0x91, 0xc2, 0xd5, 0x97, 0xc1, 0x8b, 0xd0, 0x3c, 0x13, 0xba, 0xf0, 0xd7 |
34 }; | 34 }; |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 class AuraDesktopCapturerTest : public testing::Test, | 37 class AuraScreenCapturerTest : public testing::Test, |
38 public webrtc::DesktopCapturer::Callback { | 38 public webrtc::DesktopCapturer::Callback { |
39 public: | 39 public: |
40 AuraDesktopCapturerTest() {} | 40 AuraScreenCapturerTest() {} |
41 | 41 |
42 virtual void SetUp() override; | 42 virtual void SetUp() override; |
43 | 43 |
44 MOCK_METHOD1(CreateSharedMemory, webrtc::SharedMemory*(size_t size)); | 44 MOCK_METHOD1(CreateSharedMemory, webrtc::SharedMemory*(size_t size)); |
45 MOCK_METHOD1(OnCaptureCompleted, void(webrtc::DesktopFrame* frame)); | 45 MOCK_METHOD1(OnCaptureCompleted, void(webrtc::DesktopFrame* frame)); |
46 | 46 |
47 protected: | 47 protected: |
48 void SimulateFrameCapture() { | 48 void SimulateFrameCapture() { |
49 scoped_ptr<SkBitmap> bitmap(new SkBitmap()); | 49 scoped_ptr<SkBitmap> bitmap(new SkBitmap()); |
50 const SkImageInfo& info = | 50 const SkImageInfo& info = |
51 SkImageInfo::Make(3, 4, kRGBA_8888_SkColorType, kPremul_SkAlphaType); | 51 SkImageInfo::Make(3, 4, kBGRA_8888_SkColorType, kPremul_SkAlphaType); |
52 bitmap->installPixels(info, const_cast<unsigned char*>(frame_data), 12); | 52 bitmap->installPixels(info, const_cast<unsigned char*>(frame_data), 12); |
53 | 53 |
54 scoped_ptr<cc::CopyOutputResult> output = | 54 scoped_ptr<cc::CopyOutputResult> output = |
55 cc::CopyOutputResult::CreateBitmapResult(bitmap.Pass()); | 55 cc::CopyOutputResult::CreateBitmapResult(bitmap.Pass()); |
56 capturer_->OnFrameCaptured(output.Pass()); | 56 capturer_->OnFrameCaptured(output.Pass()); |
57 } | 57 } |
58 | 58 |
59 scoped_ptr<AuraDesktopCapturer> capturer_; | 59 scoped_ptr<AuraScreenCapturer> capturer_; |
60 }; | 60 }; |
61 | 61 |
62 void AuraDesktopCapturerTest::SetUp() { | 62 void AuraScreenCapturerTest::SetUp() { |
63 capturer_.reset(new AuraDesktopCapturer()); | 63 capturer_.reset(new AuraScreenCapturer()); |
64 } | 64 } |
65 | 65 |
66 TEST_F(AuraDesktopCapturerTest, ConvertSkBitmapToDesktopFrame) { | 66 TEST_F(AuraScreenCapturerTest, ConvertSkBitmapToDesktopFrame) { |
67 webrtc::DesktopFrame* captured_frame = NULL; | 67 webrtc::DesktopFrame* captured_frame = NULL; |
68 | 68 |
69 EXPECT_CALL(*this, OnCaptureCompleted(_)).Times(1).WillOnce( | 69 EXPECT_CALL(*this, OnCaptureCompleted(_)).Times(1).WillOnce( |
70 SaveArg<0>(&captured_frame)); | 70 SaveArg<0>(&captured_frame)); |
71 capturer_->Start(this); | 71 capturer_->Start(this); |
72 | 72 |
73 SimulateFrameCapture(); | 73 SimulateFrameCapture(); |
74 | 74 |
75 ASSERT_TRUE(captured_frame != NULL); | 75 ASSERT_TRUE(captured_frame != NULL); |
76 uint8_t* captured_data = captured_frame->data(); | 76 uint8_t* captured_data = captured_frame->data(); |
77 EXPECT_EQ( | 77 EXPECT_EQ( |
78 0, | 78 0, |
79 memcmp( | 79 memcmp( |
80 frame_data, captured_data, sizeof(frame_data))); | 80 frame_data, captured_data, sizeof(frame_data))); |
81 | 81 |
82 delete captured_frame; | 82 delete captured_frame; |
83 } | 83 } |
84 | 84 |
85 } // namespace remoting | 85 } // namespace remoting |
OLD | NEW |