OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback.h" | 12 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace remoting { | 16 namespace remoting { |
16 | 17 |
17 class CapturerMacTest : public testing::Test { | 18 class CapturerMacTest : public testing::Test { |
18 protected: | 19 protected: |
19 virtual void SetUp() { | 20 virtual void SetUp() { |
20 capturer_.reset(Capturer::Create()); | 21 capturer_.reset(Capturer::Create()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), | 82 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), |
82 abs(planes.strides[0])); | 83 abs(planes.strides[0])); |
83 EXPECT_EQ(0, planes.strides[1]); | 84 EXPECT_EQ(0, planes.strides[1]); |
84 EXPECT_EQ(0, planes.strides[2]); | 85 EXPECT_EQ(0, planes.strides[2]); |
85 } | 86 } |
86 | 87 |
87 TEST_F(CapturerMacTest, Capture) { | 88 TEST_F(CapturerMacTest, Capture) { |
88 SCOPED_TRACE(""); | 89 SCOPED_TRACE(""); |
89 // Check that we get an initial full-screen updated. | 90 // Check that we get an initial full-screen updated. |
90 CapturerCallback1 callback1; | 91 CapturerCallback1 callback1; |
91 capturer_->CaptureInvalidRegion( | 92 capturer_->CaptureInvalidRegion(base::Bind( |
92 NewCallback(&callback1, &CapturerCallback1::CaptureDoneCallback)); | 93 &CapturerCallback1::CaptureDoneCallback, base::Unretained(&callback1))); |
93 // Check that subsequent dirty rects are propagated correctly. | 94 // Check that subsequent dirty rects are propagated correctly. |
94 AddDirtyRect(); | 95 AddDirtyRect(); |
95 CapturerCallback2 callback2(region_); | 96 CapturerCallback2 callback2(region_); |
96 capturer_->InvalidateRegion(region_); | 97 capturer_->InvalidateRegion(region_); |
97 capturer_->CaptureInvalidRegion( | 98 capturer_->CaptureInvalidRegion(base::Bind( |
98 NewCallback(&callback2, &CapturerCallback2::CaptureDoneCallback)); | 99 &CapturerCallback2::CaptureDoneCallback, base::Unretained(&callback2))); |
99 } | 100 } |
100 | 101 |
101 } // namespace remoting | 102 } // namespace remoting |
102 | 103 |
103 namespace gfx { | 104 namespace gfx { |
104 | 105 |
105 std::ostream& operator<<(std::ostream& out, const SkRegion& region) { | 106 std::ostream& operator<<(std::ostream& out, const SkRegion& region) { |
106 out << "SkRegion("; | 107 out << "SkRegion("; |
107 for (SkRegion::Iterator i(region); !i.done(); i.next()) { | 108 for (SkRegion::Iterator i(region); !i.done(); i.next()) { |
108 const SkIRect& r = i.rect(); | 109 const SkIRect& r = i.rect(); |
109 out << "(" << r.fLeft << "," << r.fTop << "," | 110 out << "(" << r.fLeft << "," << r.fTop << "," |
110 << r.fRight << "," << r.fBottom << ")"; | 111 << r.fRight << "," << r.fBottom << ")"; |
111 } | 112 } |
112 out << ")"; | 113 out << ")"; |
113 return out; | 114 return out; |
114 } | 115 } |
115 | 116 |
116 } // namespace gfx | 117 } // namespace gfx |
OLD | NEW |