blob: f1f0d6c2d0ef8f9655d4131ebbbd862bbc60f6cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <ApplicationServices/ApplicationServices.h>
#include <iostream>
#include "base/callback.h"
#include "base/scoped_ptr.h"
#include "remoting/base/types.h"
#include "remoting/host/capturer_mac.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace remoting {
class CapturerMacTest : public testing::Test {
protected:
virtual void SetUp() {
capturer_.reset(new CapturerMac(NULL));
capturer_->ScreenConfigurationChanged();
rects_.insert(gfx::Rect(0, 0, 10, 10));
}
scoped_ptr<CapturerMac> capturer_;
InvalidRects rects_;
};
class CapturerCallback {
public:
explicit CapturerCallback(const InvalidRects& rects) : rects_(rects) { }
void CaptureDoneCallback(scoped_refptr<CaptureData> capture_data);
protected:
InvalidRects rects_;
private:
DISALLOW_COPY_AND_ASSIGN(CapturerCallback);
};
void CapturerCallback::CaptureDoneCallback(
scoped_refptr<CaptureData> capture_data) {
CGDirectDisplayID mainDevice = CGMainDisplayID();
int width = CGDisplayPixelsWide(mainDevice);
int height = CGDisplayPixelsHigh(mainDevice);
EXPECT_EQ(rects_, capture_data->dirty_rects());
EXPECT_EQ(width, capture_data->width());
EXPECT_EQ(height, capture_data->height());
const DataPlanes &planes = capture_data->data_planes();
EXPECT_TRUE(planes.data[0] != NULL);
EXPECT_TRUE(planes.data[1] == NULL);
EXPECT_TRUE(planes.data[2] == NULL);
EXPECT_EQ(static_cast<int>(sizeof(uint32_t) * width),
planes.strides[0]);
EXPECT_EQ(0, planes.strides[1]);
EXPECT_EQ(0, planes.strides[2]);
}
TEST_F(CapturerMacTest, Capture) {
SCOPED_TRACE("");
CapturerCallback capturer(rects_);
capturer_->InvalidateRects(rects_);
capturer_->CaptureInvalidRects(
NewCallback(&capturer, &CapturerCallback::CaptureDoneCallback));
}
} // namespace remoting
namespace gfx {
std::ostream& operator<<(std::ostream& out,
const remoting::InvalidRects& rects) {
for (remoting::InvalidRects::const_iterator i = rects.begin();
i != rects.end();
++i) {
out << *i << std::endl;
}
return out;
}
} // namespace gfx
|