Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: remoting/host/video_frame_capturer_unittest.cc

Issue 10825302: mac: Remove more 10.5-only code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 10.8 Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/video_frame_capturer.h" 5 #include "remoting/host/video_frame_capturer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #if defined(OS_MACOSX) 8 #if defined(OS_MACOSX)
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #endif // defined(OS_MACOSX) 10 #endif // defined(OS_MACOSX)
11 #include "remoting/base/capture_data.h" 11 #include "remoting/base/capture_data.h"
12 #include "remoting/host/host_mock_objects.h" 12 #include "remoting/host/host_mock_objects.h"
13 #include "remoting/protocol/protocol_mock_objects.h" 13 #include "remoting/protocol/protocol_mock_objects.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 18
19 namespace { 19 namespace {
20 20
21 bool IsOsSupported() {
22 #if defined(OS_MACOSX)
23 // Verify that the OS is at least Snow Leopard (10.6).
24 // Chromoting doesn't support 10.5 or earlier.
25 return base::mac::IsOSSnowLeopardOrLater();
26 #else
27 return true;
28 #endif
29 }
30
31 void IgnoreCursorShapeChanged(scoped_ptr<protocol::CursorShapeInfo> info) { 21 void IgnoreCursorShapeChanged(scoped_ptr<protocol::CursorShapeInfo> info) {
32 } 22 }
33 23
34 } // namespace 24 } // namespace
35 25
36 MATCHER(DirtyRegionIsNonEmptyRect, "") { 26 MATCHER(DirtyRegionIsNonEmptyRect, "") {
37 const SkRegion& dirty_region = arg->dirty_region(); 27 const SkRegion& dirty_region = arg->dirty_region();
38 const SkIRect& dirty_region_bounds = dirty_region.getBounds(); 28 const SkIRect& dirty_region_bounds = dirty_region.getBounds();
39 if (dirty_region_bounds.isEmpty()) { 29 if (dirty_region_bounds.isEmpty()) {
40 return false; 30 return false;
41 } 31 }
42 return dirty_region == SkRegion(dirty_region_bounds); 32 return dirty_region == SkRegion(dirty_region_bounds);
43 } 33 }
44 34
45 class VideoFrameCapturerTest : public testing::Test { 35 class VideoFrameCapturerTest : public testing::Test {
46 protected: 36 protected:
47 virtual void SetUp() OVERRIDE { 37 virtual void SetUp() OVERRIDE {
48 capturer_.reset(VideoFrameCapturer::Create()); 38 capturer_.reset(VideoFrameCapturer::Create());
49 } 39 }
50 40
51 scoped_ptr<VideoFrameCapturer> capturer_; 41 scoped_ptr<VideoFrameCapturer> capturer_;
52 MockCaptureCompletedCallback capture_completed_callback_; 42 MockCaptureCompletedCallback capture_completed_callback_;
53 }; 43 };
54 44
55 TEST_F(VideoFrameCapturerTest, StartCapturer) { 45 TEST_F(VideoFrameCapturerTest, StartCapturer) {
56 if (!IsOsSupported()) {
57 return;
58 }
59
60 capturer_->Start(base::Bind(&IgnoreCursorShapeChanged)); 46 capturer_->Start(base::Bind(&IgnoreCursorShapeChanged));
61 capturer_->Stop(); 47 capturer_->Stop();
62 } 48 }
63 49
64 TEST_F(VideoFrameCapturerTest, Capture) { 50 TEST_F(VideoFrameCapturerTest, Capture) {
65 if (!IsOsSupported()) {
66 return;
67 }
68
69 // Assume that Start() treats the screen as invalid initially. 51 // Assume that Start() treats the screen as invalid initially.
70 EXPECT_CALL(capture_completed_callback_, 52 EXPECT_CALL(capture_completed_callback_,
71 CaptureCompletedPtr(DirtyRegionIsNonEmptyRect())); 53 CaptureCompletedPtr(DirtyRegionIsNonEmptyRect()));
72 54
73 capturer_->Start(base::Bind(&IgnoreCursorShapeChanged)); 55 capturer_->Start(base::Bind(&IgnoreCursorShapeChanged));
74 capturer_->CaptureInvalidRegion(base::Bind( 56 capturer_->CaptureInvalidRegion(base::Bind(
75 &MockCaptureCompletedCallback::CaptureCompleted, 57 &MockCaptureCompletedCallback::CaptureCompleted,
76 base::Unretained(&capture_completed_callback_))); 58 base::Unretained(&capture_completed_callback_)));
77 capturer_->Stop(); 59 capturer_->Stop();
78 } 60 }
79 61
80 } // namespace remoting 62 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698