OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "cc/output/copy_output_result.h" | |
6 #include "remoting/host/chromeos/aura_desktop_capturer.h" | |
Sergey Ulanov
2014/09/10 23:08:52
this should be the first include in this file with
kelvinp
2014/09/11 20:54:17
Done.
| |
7 #include "testing/gmock/include/gmock/gmock.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 #include "third_party/skia/include/core/SkBitmap.h" | |
10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | |
11 | |
12 using testing::_; | |
13 using testing::SaveArg; | |
14 | |
15 namespace remoting { | |
16 | |
17 namespace { | |
18 | |
19 // Test frame data. | |
20 unsigned char frame_data[] = { | |
21 0x00, 0x00, 0x00, 0x9a, 0x65, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, | |
22 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x60, 0x90, | |
23 0x24, 0x71, 0xf8, 0xf2, 0xe5, 0xdf, 0x7f, 0x81, 0xc7, 0x49, 0xc4, 0xa3, | |
24 0x58, 0x5c, 0xf6, 0xcc, 0x40, 0x14, 0x28, 0x0c, 0xa0, 0xfa, 0x03, 0x18, | |
25 0x38, 0xd8, 0x7d, 0x77, 0x2b, 0x3a, 0x00, 0x00, 0x00, 0x20, 0x64, 0x46, | |
26 0x47, 0x2f, 0xdf, 0x6e, 0xed, 0x7b, 0xf3, 0xc3, 0x37, 0x20, 0xf2, 0x36, | |
27 0x67, 0x6c, 0x36, 0xe1, 0xb4, 0x5e, 0xbe, 0x04, 0x85, 0xdb, 0x89, 0xa3, | |
28 0xcd, 0xfd, 0xd2, 0x4b, 0xd6, 0x9f, 0x00, 0x00, 0x00, 0x40, 0x38, 0x35, | |
29 0x05, 0x75, 0x1d, 0x13, 0x6e, 0xb3, 0x6b, 0x1d, 0x29, 0xae, 0xd3, 0x43, | |
30 0xe6, 0x84, 0x8f, 0xa3, 0x9d, 0x65, 0x4e, 0x2f, 0x57, 0xe3, 0xf6, 0xe6, | |
31 0x20, 0x3c, 0x00, 0xc6, 0xe1, 0x73, 0x34, 0xe2, 0x23, 0x99, 0xc4, 0xfa, | |
32 0x91, 0xc2, 0xd5, 0x97, 0xc1, 0x8b, 0xd0, 0x3c, 0x13, 0xba, 0xf0, 0xd7 | |
33 }; | |
34 } // namespace | |
35 | |
36 class AuraDesktopCapturerTest : public testing::Test, | |
37 public webrtc::DesktopCapturer::Callback { | |
38 public: | |
39 AuraDesktopCapturerTest() {} | |
40 | |
41 virtual void SetUp() OVERRIDE; | |
42 | |
43 MOCK_METHOD1(CreateSharedMemory, webrtc::SharedMemory*(size_t size)); | |
44 MOCK_METHOD1(OnCaptureCompleted, void(webrtc::DesktopFrame* frame)); | |
45 | |
46 protected: | |
47 void SimulateFrameCapture() { | |
48 scoped_ptr<SkBitmap> bitmap(new SkBitmap()); | |
49 const SkImageInfo& info = SkImageInfo::MakeN32Premul(3, 4); | |
50 bitmap->setInfo(info); | |
51 bitmap->setPixels(static_cast<void*>(frame_data)); | |
52 | |
53 scoped_ptr<cc::CopyOutputResult> output = | |
54 cc::CopyOutputResult::CreateBitmapResult(bitmap.Pass()); | |
55 capturer_->OnFrameCaptured(output.Pass()); | |
56 } | |
57 | |
58 scoped_ptr<AuraDesktopCapturer> capturer_; | |
59 }; | |
60 | |
61 void AuraDesktopCapturerTest::SetUp() { | |
62 capturer_.reset(new AuraDesktopCapturer()); | |
63 } | |
64 | |
65 TEST_F(AuraDesktopCapturerTest, ConvertSkBitmapToDesktopFrame) { | |
66 webrtc::DesktopFrame* captured_frame = NULL; | |
Sergey Ulanov
2014/09/10 23:08:52
This needs to be deleted at the end. OnCaptureComp
kelvinp
2014/09/11 20:54:17
Done.
| |
67 | |
68 EXPECT_CALL(*this, OnCaptureCompleted(_)).Times(1).WillOnce( | |
69 SaveArg<0>(&captured_frame)); | |
70 capturer_->Start(this); | |
71 | |
72 SimulateFrameCapture(); | |
73 | |
74 ASSERT_TRUE(captured_frame != NULL); | |
75 uint8_t* captured_data = captured_frame->data(); | |
76 EXPECT_EQ( | |
77 0, | |
78 memcmp( | |
79 frame_data, captured_data, sizeof(uint8_t) * arraysize(frame_data))); | |
Sergey Ulanov
2014/09/10 23:08:52
sizeof(frame_data) would work here just fine and i
| |
80 } | |
81 | |
82 } // namespace remoting | |
OLD | NEW |