blob: e1a815d40484a99f9db8b1f4129ff809952590ae [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001#include "talk/base/gunit.h"
2#include "talk/base/window.h"
3#include "talk/base/windowpicker.h"
4#include "talk/base/windowpickerfactory.h"
5
6#ifdef OSX
7# define DISABLE_ON_MAC(name) DISABLED_ ## name
8#else
9# define DISABLE_ON_MAC(name) name
10#endif
11
12TEST(WindowPickerTest, GetWindowList) {
13 if (!talk_base::WindowPickerFactory::IsSupported()) {
14 LOG(LS_INFO) << "skipping test: window capturing is not supported with "
15 << "current configuration.";
16 }
17 talk_base::scoped_ptr<talk_base::WindowPicker> picker(
18 talk_base::WindowPickerFactory::CreateWindowPicker());
19 EXPECT_TRUE(picker->Init());
20 talk_base::WindowDescriptionList descriptions;
21 EXPECT_TRUE(picker->GetWindowList(&descriptions));
22}
23
24// TODO(hughv) Investigate why this fails on pulse but not locally after
25// upgrading to XCode 4.5. The failure is GetDesktopList returning FALSE.
26TEST(WindowPickerTest, DISABLE_ON_MAC(GetDesktopList)) {
27 if (!talk_base::WindowPickerFactory::IsSupported()) {
28 LOG(LS_INFO) << "skipping test: window capturing is not supported with "
29 << "current configuration.";
30 }
31 talk_base::scoped_ptr<talk_base::WindowPicker> picker(
32 talk_base::WindowPickerFactory::CreateWindowPicker());
33 EXPECT_TRUE(picker->Init());
34 talk_base::DesktopDescriptionList descriptions;
35 EXPECT_TRUE(picker->GetDesktopList(&descriptions));
36 if (descriptions.size() > 0) {
37 int width = 0;
38 int height = 0;
39 EXPECT_TRUE(picker->GetDesktopDimensions(descriptions[0].id(), &width,
40 &height));
41 EXPECT_GT(width, 0);
42 EXPECT_GT(height, 0);
43
44 // Test |IsPrimaryDesktop|. Only one desktop should be a primary.
45 bool found_primary = false;
46 for (talk_base::DesktopDescriptionList::iterator it = descriptions.begin();
47 it != descriptions.end(); ++it) {
48 if (it->primary()) {
49 EXPECT_FALSE(found_primary);
50 found_primary = true;
51 }
52 }
53 EXPECT_TRUE(found_primary);
54 }
55}