- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / libjingle / source / talk / base / windowpicker_unittest.cc
1 #include "talk/base/gunit.h"
2 #include "talk/base/testutils.h"
3 #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
13 TEST(WindowPickerTest, GetWindowList) {
14   MAYBE_SKIP_SCREENCAST_TEST();
15   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.
28 TEST(WindowPickerTest, DISABLE_ON_MAC(GetDesktopList)) {
29   MAYBE_SKIP_SCREENCAST_TEST();
30   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 }