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