| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/capturer.h" | 5 #include "remoting/host/capturer.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 | 8 |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "remoting/base/capture_data.h" |
| 15 #include "remoting/proto/control.pb.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 17 |
| 16 namespace remoting { | 18 namespace remoting { |
| 17 | 19 |
| 18 class CapturerMacTest : public testing::Test { | 20 class CapturerMacTest : public testing::Test { |
| 19 protected: | 21 protected: |
| 20 virtual void SetUp() { | 22 virtual void SetUp() { |
| 21 capturer_.reset(Capturer::Create()); | 23 capturer_.reset(Capturer::Create()); |
| 22 } | 24 } |
| 23 | 25 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 EXPECT_TRUE(planes.data[1] == NULL); | 80 EXPECT_TRUE(planes.data[1] == NULL); |
| 79 EXPECT_TRUE(planes.data[2] == NULL); | 81 EXPECT_TRUE(planes.data[2] == NULL); |
| 80 // Depending on the capture method, the screen may be flipped or not, so | 82 // Depending on the capture method, the screen may be flipped or not, so |
| 81 // the stride may be positive or negative. | 83 // the stride may be positive or negative. |
| 82 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), | 84 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), |
| 83 abs(planes.strides[0])); | 85 abs(planes.strides[0])); |
| 84 EXPECT_EQ(0, planes.strides[1]); | 86 EXPECT_EQ(0, planes.strides[1]); |
| 85 EXPECT_EQ(0, planes.strides[2]); | 87 EXPECT_EQ(0, planes.strides[2]); |
| 86 } | 88 } |
| 87 | 89 |
| 90 class CursorCallback { |
| 91 public: |
| 92 CursorCallback() { } |
| 93 void CursorShapeChangedCallback( |
| 94 scoped_ptr<protocol::CursorShapeInfo> cursor_data); |
| 95 |
| 96 private: |
| 97 DISALLOW_COPY_AND_ASSIGN(CursorCallback); |
| 98 }; |
| 99 |
| 100 void CursorCallback::CursorShapeChangedCallback( |
| 101 scoped_ptr<protocol::CursorShapeInfo> cursor_data) { |
| 102 } |
| 103 |
| 88 TEST_F(CapturerMacTest, Capture) { | 104 TEST_F(CapturerMacTest, Capture) { |
| 89 SCOPED_TRACE(""); | 105 SCOPED_TRACE(""); |
| 90 capturer_->Start(); | 106 CursorCallback cursor_callback; |
| 107 capturer_->Start(base::Bind(&CursorCallback::CursorShapeChangedCallback, |
| 108 base::Unretained(&cursor_callback))); |
| 91 // Check that we get an initial full-screen updated. | 109 // Check that we get an initial full-screen updated. |
| 92 CapturerCallback1 callback1; | 110 CapturerCallback1 callback1; |
| 93 capturer_->CaptureInvalidRegion(base::Bind( | 111 capturer_->CaptureInvalidRegion(base::Bind( |
| 94 &CapturerCallback1::CaptureDoneCallback, base::Unretained(&callback1))); | 112 &CapturerCallback1::CaptureDoneCallback, base::Unretained(&callback1))); |
| 95 // Check that subsequent dirty rects are propagated correctly. | 113 // Check that subsequent dirty rects are propagated correctly. |
| 96 AddDirtyRect(); | 114 AddDirtyRect(); |
| 97 CapturerCallback2 callback2(region_); | 115 CapturerCallback2 callback2(region_); |
| 98 capturer_->InvalidateRegion(region_); | 116 capturer_->InvalidateRegion(region_); |
| 99 capturer_->CaptureInvalidRegion(base::Bind( | 117 capturer_->CaptureInvalidRegion(base::Bind( |
| 100 &CapturerCallback2::CaptureDoneCallback, base::Unretained(&callback2))); | 118 &CapturerCallback2::CaptureDoneCallback, base::Unretained(&callback2))); |
| 101 capturer_->Stop(); | 119 capturer_->Stop(); |
| 102 } | 120 } |
| 103 | 121 |
| 104 } // namespace remoting | 122 } // namespace remoting |
| 105 | 123 |
| 106 namespace gfx { | 124 namespace gfx { |
| 107 | 125 |
| 108 std::ostream& operator<<(std::ostream& out, const SkRegion& region) { | 126 std::ostream& operator<<(std::ostream& out, const SkRegion& region) { |
| 109 out << "SkRegion("; | 127 out << "SkRegion("; |
| 110 for (SkRegion::Iterator i(region); !i.done(); i.next()) { | 128 for (SkRegion::Iterator i(region); !i.done(); i.next()) { |
| 111 const SkIRect& r = i.rect(); | 129 const SkIRect& r = i.rect(); |
| 112 out << "(" << r.fLeft << "," << r.fTop << "," | 130 out << "(" << r.fLeft << "," << r.fTop << "," |
| 113 << r.fRight << "," << r.fBottom << ")"; | 131 << r.fRight << "," << r.fBottom << ")"; |
| 114 } | 132 } |
| 115 out << ")"; | 133 out << ")"; |
| 116 return out; | 134 return out; |
| 117 } | 135 } |
| 118 | 136 |
| 119 } // namespace gfx | 137 } // namespace gfx |
| OLD | NEW |