Home | History | Annotate | Download | only in base
      1 /*
      2  *  Copyright 2012 The WebRTC Project Authors. All rights reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 #include "webrtc/base/gunit.h"
     11 #include "webrtc/base/testutils.h"
     12 #include "webrtc/base/window.h"
     13 #include "webrtc/base/windowpicker.h"
     14 #include "webrtc/base/windowpickerfactory.h"
     15 
     16 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
     17 #  define DISABLE_ON_MAC(name) DISABLED_ ## name
     18 #else
     19 #  define DISABLE_ON_MAC(name) name
     20 #endif
     21 
     22 TEST(WindowPickerTest, GetWindowList) {
     23   MAYBE_SKIP_SCREENCAST_TEST();
     24   if (!rtc::WindowPickerFactory::IsSupported()) {
     25     LOG(LS_INFO) << "skipping test: window capturing is not supported with "
     26                  << "current configuration.";
     27   }
     28   rtc::scoped_ptr<rtc::WindowPicker> picker(
     29       rtc::WindowPickerFactory::CreateWindowPicker());
     30   EXPECT_TRUE(picker->Init());
     31   rtc::WindowDescriptionList descriptions;
     32   EXPECT_TRUE(picker->GetWindowList(&descriptions));
     33 }
     34 
     35 // TODO(hughv) Investigate why this fails on pulse but not locally after
     36 // upgrading to XCode 4.5.  The failure is GetDesktopList returning FALSE.
     37 TEST(WindowPickerTest, DISABLE_ON_MAC(GetDesktopList)) {
     38   MAYBE_SKIP_SCREENCAST_TEST();
     39   if (!rtc::WindowPickerFactory::IsSupported()) {
     40     LOG(LS_INFO) << "skipping test: window capturing is not supported with "
     41                  << "current configuration.";
     42   }
     43   rtc::scoped_ptr<rtc::WindowPicker> picker(
     44       rtc::WindowPickerFactory::CreateWindowPicker());
     45   EXPECT_TRUE(picker->Init());
     46   rtc::DesktopDescriptionList descriptions;
     47   EXPECT_TRUE(picker->GetDesktopList(&descriptions));
     48   if (descriptions.size() > 0) {
     49     int width = 0;
     50     int height = 0;
     51     EXPECT_TRUE(picker->GetDesktopDimensions(descriptions[0].id(), &width,
     52                                              &height));
     53     EXPECT_GT(width, 0);
     54     EXPECT_GT(height, 0);
     55 
     56     // Test |IsPrimaryDesktop|. Only one desktop should be a primary.
     57     bool found_primary = false;
     58     for (rtc::DesktopDescriptionList::iterator it = descriptions.begin();
     59          it != descriptions.end(); ++it) {
     60       if (it->primary()) {
     61         EXPECT_FALSE(found_primary);
     62         found_primary = true;
     63       }
     64     }
     65     EXPECT_TRUE(found_primary);
     66   }
     67 }
     68