• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2010 Google Inc. All Rights Reserved
2 
3 
4 #include "talk/base/gunit.h"
5 #include "talk/base/logging.h"
6 #include "talk/base/macutils.h"
7 #include "talk/base/macwindowpicker.h"
8 #include "talk/base/windowpicker.h"
9 
10 #ifndef OSX
11 #error Only for Mac OSX
12 #endif
13 
14 namespace talk_base {
15 
IsLeopardOrLater()16 bool IsLeopardOrLater() {
17   return GetOSVersionName() >= kMacOSLeopard;
18 }
19 
20 // Test that this works on new versions and fails acceptably on old versions.
TEST(MacWindowPickerTest,TestGetWindowList)21 TEST(MacWindowPickerTest, TestGetWindowList) {
22   MacWindowPicker picker, picker2;
23   WindowDescriptionList descriptions;
24   if (IsLeopardOrLater()) {
25     EXPECT_TRUE(picker.Init());
26     EXPECT_TRUE(picker.GetWindowList(&descriptions));
27     EXPECT_TRUE(picker2.GetWindowList(&descriptions));  // Init is optional
28   } else {
29     EXPECT_FALSE(picker.Init());
30     EXPECT_FALSE(picker.GetWindowList(&descriptions));
31     EXPECT_FALSE(picker2.GetWindowList(&descriptions));
32   }
33 }
34 
35 // TODO: Add verification of the actual parsing, ie, add
36 // functionality to inject a fake get_window_array function which
37 // provide a pre-constructed list of windows.
38 
39 }  // namespace talk_base
40