OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <ApplicationServices/ApplicationServices.h> | 5 #include <ApplicationServices/ApplicationServices.h> |
6 | 6 |
7 #include <iostream> | 7 #include <iostream> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 10 matching lines...) Loading... |
21 rects_.push_back(gfx::Rect(0, 0, 10, 10)); | 21 rects_.push_back(gfx::Rect(0, 0, 10, 10)); |
22 } | 22 } |
23 | 23 |
24 scoped_ptr<CapturerMac> capturer_; | 24 scoped_ptr<CapturerMac> capturer_; |
25 RectVector rects_; | 25 RectVector rects_; |
26 }; | 26 }; |
27 | 27 |
28 class CapturerCallback { | 28 class CapturerCallback { |
29 public: | 29 public: |
30 explicit CapturerCallback(const RectVector& rects) : rects_(rects) { } | 30 explicit CapturerCallback(const RectVector& rects) : rects_(rects) { } |
31 void CaptureDoneCallback(scoped_refptr<Capturer::CaptureData> capture_data); | 31 void CaptureDoneCallback(scoped_refptr<CaptureData> capture_data); |
32 | 32 |
33 protected: | 33 protected: |
34 RectVector rects_; | 34 RectVector rects_; |
35 | 35 |
36 private: | 36 private: |
37 DISALLOW_COPY_AND_ASSIGN(CapturerCallback); | 37 DISALLOW_COPY_AND_ASSIGN(CapturerCallback); |
38 }; | 38 }; |
39 | 39 |
40 void CapturerCallback::CaptureDoneCallback( | 40 void CapturerCallback::CaptureDoneCallback( |
41 scoped_refptr<Capturer::CaptureData> capture_data) { | 41 scoped_refptr<CaptureData> capture_data) { |
42 CGDirectDisplayID mainDevice = CGMainDisplayID(); | 42 CGDirectDisplayID mainDevice = CGMainDisplayID(); |
43 int width = CGDisplayPixelsWide(mainDevice); | 43 int width = CGDisplayPixelsWide(mainDevice); |
44 int height = CGDisplayPixelsHigh(mainDevice); | 44 int height = CGDisplayPixelsHigh(mainDevice); |
45 | 45 |
46 EXPECT_EQ(rects_, capture_data->dirty_rects()); | 46 EXPECT_EQ(rects_, capture_data->dirty_rects()); |
47 EXPECT_EQ(width, capture_data->width()); | 47 EXPECT_EQ(width, capture_data->width()); |
48 EXPECT_EQ(height, capture_data->height()); | 48 EXPECT_EQ(height, capture_data->height()); |
49 const Capturer::DataPlanes &planes = capture_data->data_planes(); | 49 const DataPlanes &planes = capture_data->data_planes(); |
50 EXPECT_TRUE(planes.data[0] != NULL); | 50 EXPECT_TRUE(planes.data[0] != NULL); |
51 EXPECT_TRUE(planes.data[1] == NULL); | 51 EXPECT_TRUE(planes.data[1] == NULL); |
52 EXPECT_TRUE(planes.data[2] == NULL); | 52 EXPECT_TRUE(planes.data[2] == NULL); |
53 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), | 53 EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width), |
54 planes.strides[0]); | 54 planes.strides[0]); |
55 EXPECT_EQ(0, planes.strides[1]); | 55 EXPECT_EQ(0, planes.strides[1]); |
56 EXPECT_EQ(0, planes.strides[2]); | 56 EXPECT_EQ(0, planes.strides[2]); |
57 } | 57 } |
58 | 58 |
59 TEST_F(CapturerMacTest, Capture) { | 59 TEST_F(CapturerMacTest, Capture) { |
60 SCOPED_TRACE(""); | 60 SCOPED_TRACE(""); |
61 CapturerCallback capturer(rects_); | 61 CapturerCallback capturer(rects_); |
62 capturer_->InvalidateRects(rects_); | 62 capturer_->InvalidateRects(rects_); |
63 capturer_->CaptureInvalidRects( | 63 capturer_->CaptureInvalidRects( |
64 NewCallback(&capturer, &CapturerCallback::CaptureDoneCallback)); | 64 NewCallback(&capturer, &CapturerCallback::CaptureDoneCallback)); |
65 } | 65 } |
66 | 66 |
67 } // namespace remoting | 67 } // namespace remoting |
68 | 68 |
69 std::ostream& operator<<(std::ostream& out, const remoting::RectVector& rects) { | 69 std::ostream& operator<<(std::ostream& out, const remoting::RectVector& rects) { |
70 for (remoting::RectVector::const_iterator i = rects.begin(); | 70 for (remoting::RectVector::const_iterator i = rects.begin(); |
71 i < rects.end(); | 71 i < rects.end(); |
72 ++i) { | 72 ++i) { |
73 out << *i << std::endl; | 73 out << *i << std::endl; |
74 } | 74 } |
75 return out; | 75 return out; |
76 } | 76 } |
OLD | NEW |