| 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_desktop_capturer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 public webrtc::DesktopCapturer::Callback { | 43 public webrtc::DesktopCapturer::Callback { |
| 44 public: | 44 public: |
| 45 AuraDesktopCapturerTest() {} | 45 AuraDesktopCapturerTest() {} |
| 46 | 46 |
| 47 void SetUp() override; | 47 void SetUp() override; |
| 48 | 48 |
| 49 MOCK_METHOD1(OnCaptureCompleted, void(webrtc::DesktopFrame* frame)); | 49 MOCK_METHOD1(OnCaptureCompleted, void(webrtc::DesktopFrame* frame)); |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 void SimulateFrameCapture() { | 52 void SimulateFrameCapture() { |
| 53 scoped_ptr<SkBitmap> bitmap(new SkBitmap()); | 53 std::unique_ptr<SkBitmap> bitmap(new SkBitmap()); |
| 54 const SkImageInfo& info = | 54 const SkImageInfo& info = |
| 55 SkImageInfo::Make(3, 4, kBGRA_8888_SkColorType, kPremul_SkAlphaType); | 55 SkImageInfo::Make(3, 4, kBGRA_8888_SkColorType, kPremul_SkAlphaType); |
| 56 bitmap->installPixels(info, const_cast<unsigned char*>(frame_data), 12); | 56 bitmap->installPixels(info, const_cast<unsigned char*>(frame_data), 12); |
| 57 | 57 |
| 58 capturer_->OnFrameCaptured( | 58 capturer_->OnFrameCaptured( |
| 59 cc::CopyOutputResult::CreateBitmapResult(std::move(bitmap))); | 59 cc::CopyOutputResult::CreateBitmapResult(std::move(bitmap))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 scoped_ptr<AuraDesktopCapturer> capturer_; | 62 std::unique_ptr<AuraDesktopCapturer> capturer_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 void AuraDesktopCapturerTest::SetUp() { | 65 void AuraDesktopCapturerTest::SetUp() { |
| 66 capturer_.reset(new AuraDesktopCapturer()); | 66 capturer_.reset(new AuraDesktopCapturer()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 TEST_F(AuraDesktopCapturerTest, ConvertSkBitmapToDesktopFrame) { | 69 TEST_F(AuraDesktopCapturerTest, ConvertSkBitmapToDesktopFrame) { |
| 70 webrtc::DesktopFrame* captured_frame = nullptr; | 70 webrtc::DesktopFrame* captured_frame = nullptr; |
| 71 | 71 |
| 72 EXPECT_CALL(*this, OnCaptureCompleted(_)).Times(1).WillOnce( | 72 EXPECT_CALL(*this, OnCaptureCompleted(_)).Times(1).WillOnce( |
| 73 SaveArg<0>(&captured_frame)); | 73 SaveArg<0>(&captured_frame)); |
| 74 capturer_->Start(this); | 74 capturer_->Start(this); |
| 75 | 75 |
| 76 SimulateFrameCapture(); | 76 SimulateFrameCapture(); |
| 77 | 77 |
| 78 ASSERT_TRUE(captured_frame != nullptr); | 78 ASSERT_TRUE(captured_frame != nullptr); |
| 79 uint8_t* captured_data = captured_frame->data(); | 79 uint8_t* captured_data = captured_frame->data(); |
| 80 EXPECT_EQ( | 80 EXPECT_EQ( |
| 81 0, | 81 0, |
| 82 memcmp( | 82 memcmp( |
| 83 frame_data, captured_data, sizeof(frame_data))); | 83 frame_data, captured_data, sizeof(frame_data))); |
| 84 | 84 |
| 85 delete captured_frame; | 85 delete captured_frame; |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace remoting | 88 } // namespace remoting |
| OLD | NEW |