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/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 "base/message_loop.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace remoting { | 17 namespace remoting { |
17 | 18 |
18 class CapturerMacTest : public testing::Test { | 19 class CapturerMacTest : public testing::Test { |
19 protected: | 20 protected: |
20 virtual void SetUp() { | 21 virtual void SetUp() { |
21 capturer_.reset(Capturer::Create()); | 22 capturer_.reset(Capturer::Create()); |
22 } | 23 } |
23 | 24 |
24 void AddDirtyRect() { | 25 void AddDirtyRect() { |
25 SkIRect rect = SkIRect::MakeXYWH(0, 0, 10, 10); | 26 SkIRect rect = SkIRect::MakeXYWH(0, 0, 10, 10); |
26 region_.op(rect, SkRegion::kUnion_Op); | 27 region_.op(rect, SkRegion::kUnion_Op); |
27 } | 28 } |
28 | 29 |
29 scoped_ptr<Capturer> capturer_; | 30 scoped_ptr<Capturer> capturer_; |
30 SkRegion region_; | 31 SkRegion region_; |
| 32 MessageLoop message_loop_; |
31 }; | 33 }; |
32 | 34 |
33 // CapturerCallback1 verifies that the whole screen is initially dirty. | 35 // CapturerCallback1 verifies that the whole screen is initially dirty. |
34 class CapturerCallback1 { | 36 class CapturerCallback1 { |
35 public: | 37 public: |
36 CapturerCallback1() { } | 38 CapturerCallback1() { } |
37 void CaptureDoneCallback(scoped_refptr<CaptureData> capture_data); | 39 void CaptureDoneCallback(scoped_refptr<CaptureData> capture_data); |
38 | 40 |
39 private: | 41 private: |
40 DISALLOW_COPY_AND_ASSIGN(CapturerCallback1); | 42 DISALLOW_COPY_AND_ASSIGN(CapturerCallback1); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Check that we get an initial full-screen updated. | 92 // Check that we get an initial full-screen updated. |
91 CapturerCallback1 callback1; | 93 CapturerCallback1 callback1; |
92 capturer_->CaptureInvalidRegion(base::Bind( | 94 capturer_->CaptureInvalidRegion(base::Bind( |
93 &CapturerCallback1::CaptureDoneCallback, base::Unretained(&callback1))); | 95 &CapturerCallback1::CaptureDoneCallback, base::Unretained(&callback1))); |
94 // Check that subsequent dirty rects are propagated correctly. | 96 // Check that subsequent dirty rects are propagated correctly. |
95 AddDirtyRect(); | 97 AddDirtyRect(); |
96 CapturerCallback2 callback2(region_); | 98 CapturerCallback2 callback2(region_); |
97 capturer_->InvalidateRegion(region_); | 99 capturer_->InvalidateRegion(region_); |
98 capturer_->CaptureInvalidRegion(base::Bind( | 100 capturer_->CaptureInvalidRegion(base::Bind( |
99 &CapturerCallback2::CaptureDoneCallback, base::Unretained(&callback2))); | 101 &CapturerCallback2::CaptureDoneCallback, base::Unretained(&callback2))); |
| 102 message_loop_.RunAllPending(); |
100 } | 103 } |
101 | 104 |
102 } // namespace remoting | 105 } // namespace remoting |
103 | 106 |
104 namespace gfx { | 107 namespace gfx { |
105 | 108 |
106 std::ostream& operator<<(std::ostream& out, const SkRegion& region) { | 109 std::ostream& operator<<(std::ostream& out, const SkRegion& region) { |
107 out << "SkRegion("; | 110 out << "SkRegion("; |
108 for (SkRegion::Iterator i(region); !i.done(); i.next()) { | 111 for (SkRegion::Iterator i(region); !i.done(); i.next()) { |
109 const SkIRect& r = i.rect(); | 112 const SkIRect& r = i.rect(); |
110 out << "(" << r.fLeft << "," << r.fTop << "," | 113 out << "(" << r.fLeft << "," << r.fTop << "," |
111 << r.fRight << "," << r.fBottom << ")"; | 114 << r.fRight << "," << r.fBottom << ")"; |
112 } | 115 } |
113 out << ")"; | 116 out << ")"; |
114 return out; | 117 return out; |
115 } | 118 } |
116 | 119 |
117 } // namespace gfx | 120 } // namespace gfx |
OLD | NEW |