summaryrefslogtreecommitdiff
path: root/chromium/third_party/libjingle/source/talk/base/macwindowpicker_unittest.cc
blob: 9cb67db9ea4ef7d93842dbcc756ebd69121bbd2a (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
// Copyright 2010 Google Inc. All Rights Reserved


#include "talk/base/gunit.h"
#include "talk/base/logging.h"
#include "talk/base/macutils.h"
#include "talk/base/macwindowpicker.h"
#include "talk/base/windowpicker.h"

#ifndef OSX
#error Only for Mac OSX
#endif

namespace talk_base {

bool IsLeopardOrLater() {
  return GetOSVersionName() >= kMacOSLeopard;
}

// Test that this works on new versions and fails acceptably on old versions.
TEST(MacWindowPickerTest, TestGetWindowList) {
  MacWindowPicker picker, picker2;
  WindowDescriptionList descriptions;
  if (IsLeopardOrLater()) {
    EXPECT_TRUE(picker.Init());
    EXPECT_TRUE(picker.GetWindowList(&descriptions));
    EXPECT_TRUE(picker2.GetWindowList(&descriptions));  // Init is optional
  } else {
    EXPECT_FALSE(picker.Init());
    EXPECT_FALSE(picker.GetWindowList(&descriptions));
    EXPECT_FALSE(picker2.GetWindowList(&descriptions));
  }
}

// TODO: Add verification of the actual parsing, ie, add
// functionality to inject a fake get_window_array function which
// provide a pre-constructed list of windows.

}  // namespace talk_base