OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/bind.h" | |
6 #if defined(OS_MACOSX) | |
7 #include "base/mac/mac_util.h" | |
8 #endif // defined(OS_MACOSX) | |
9 #include "remoting/base/capture_data.h" | |
10 #include "remoting/host/capturer.h" | |
11 #include "remoting/host/host_mock_objects.h" | |
12 #include "remoting/protocol/protocol_mock_objects.h" | |
13 #include "testing/gmock/include/gmock/gmock.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 | |
16 namespace remoting { | |
17 | |
18 namespace { | |
19 | |
20 bool IsOsSupported() { | |
21 #if defined(OS_MACOSX) | |
22 // Verify that the OS is at least Snow Leopard (10.6). | |
23 // Chromoting doesn't support 10.5 or earlier. | |
24 return base::mac::IsOSSnowLeopardOrLater(); | |
25 #else | |
26 return true; | |
27 #endif | |
28 } | |
29 | |
30 void IgnoreCursorShapeChanged(scoped_ptr<protocol::CursorShapeInfo> info) { | |
31 } | |
32 | |
33 } // namespace | |
34 | |
35 MATCHER(DirtyRegionIsNonEmptyRect, "") { | |
36 const SkRegion& dirty_region = arg->dirty_region(); | |
37 const SkIRect& dirty_region_bounds = dirty_region.getBounds(); | |
38 if (dirty_region_bounds.isEmpty()) { | |
39 return false; | |
40 } | |
41 return dirty_region == SkRegion(dirty_region_bounds); | |
42 } | |
43 | |
44 class CapturerTest : public testing::Test { | |
45 protected: | |
46 virtual void SetUp() { | |
47 capturer_.reset(Capturer::Create()); | |
48 } | |
49 | |
50 scoped_ptr<Capturer> capturer_; | |
51 MockCaptureCompletedCallback capture_completed_callback_; | |
52 }; | |
53 | |
54 TEST_F(CapturerTest, StartCapturer) { | |
55 if (!IsOsSupported()) { | |
56 return; | |
57 } | |
58 | |
59 capturer_->Start(base::Bind(&IgnoreCursorShapeChanged)); | |
60 capturer_->Stop(); | |
61 } | |
62 | |
63 #if defined(OS_MACOSX) | |
64 #define MAYBE_Capture DISABLED_Capture | |
65 #else | |
66 #define MAYBE_Capture Capture | |
67 #endif | |
68 | |
69 TEST_F(CapturerTest, MAYBE_Capture) { | |
70 if (!IsOsSupported()) { | |
71 return; | |
72 } | |
73 | |
74 // Assume that Start() treats the screen as invalid initially. | |
75 EXPECT_CALL(capture_completed_callback_, | |
76 CaptureCompletedPtr(DirtyRegionIsNonEmptyRect())); | |
77 | |
78 capturer_->Start(base::Bind(&IgnoreCursorShapeChanged)); | |
79 capturer_->CaptureInvalidRegion(base::Bind( | |
80 &MockCaptureCompletedCallback::CaptureCompleted, | |
81 base::Unretained(&capture_completed_callback_))); | |
82 capturer_->Stop(); | |
83 } | |
84 | |
85 } // namespace remoting | |
OLD | NEW |