• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2010 The WebRTC Project Authors. All rights reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 #include "webrtc/base/gunit.h"
11 #include "webrtc/base/logging.h"
12 #include "webrtc/base/macutils.h"
13 #include "webrtc/base/macwindowpicker.h"
14 #include "webrtc/base/windowpicker.h"
15 
16 #if !defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
17 #error Only for WEBRTC_MAC && !WEBRTC_IOS
18 #endif
19 
20 namespace rtc {
21 
IsLeopardOrLater()22 bool IsLeopardOrLater() {
23   return GetOSVersionName() >= kMacOSLeopard;
24 }
25 
26 // Test that this works on new versions and fails acceptably on old versions.
TEST(MacWindowPickerTest,TestGetWindowList)27 TEST(MacWindowPickerTest, TestGetWindowList) {
28   MacWindowPicker picker, picker2;
29   WindowDescriptionList descriptions;
30   if (IsLeopardOrLater()) {
31     EXPECT_TRUE(picker.Init());
32     EXPECT_TRUE(picker.GetWindowList(&descriptions));
33     EXPECT_TRUE(picker2.GetWindowList(&descriptions));  // Init is optional
34   } else {
35     EXPECT_FALSE(picker.Init());
36     EXPECT_FALSE(picker.GetWindowList(&descriptions));
37     EXPECT_FALSE(picker2.GetWindowList(&descriptions));
38   }
39 }
40 
41 // TODO: Add verification of the actual parsing, ie, add
42 // functionality to inject a fake get_window_array function which
43 // provide a pre-constructed list of windows.
44 
45 }  // namespace rtc
46