| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include "webrtc/base/arraysize.h" |
| 10 #include "webrtc/base/gunit.h" | 11 #include "webrtc/base/gunit.h" |
| 11 #include "webrtc/base/common.h" | 12 #include "webrtc/base/common.h" |
| 12 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
| 13 #include "webrtc/base/win32window.h" | 14 #include "webrtc/base/win32window.h" |
| 14 #include "webrtc/base/win32windowpicker.h" | 15 #include "webrtc/base/win32windowpicker.h" |
| 15 #include "webrtc/base/windowpicker.h" | 16 #include "webrtc/base/windowpicker.h" |
| 16 | 17 |
| 17 #if !defined(WEBRTC_WIN) | 18 #if !defined(WEBRTC_WIN) |
| 18 #error Only for Windows | 19 #error Only for Windows |
| 19 #endif | 20 #endif |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 65 |
| 65 TEST(Win32WindowPickerTest, TestGetWindowList) { | 66 TEST(Win32WindowPickerTest, TestGetWindowList) { |
| 66 Win32WindowPickerForTest window_picker; | 67 Win32WindowPickerForTest window_picker; |
| 67 WindowDescriptionList descriptions; | 68 WindowDescriptionList descriptions; |
| 68 EXPECT_TRUE(window_picker.GetWindowList(&descriptions)); | 69 EXPECT_TRUE(window_picker.GetWindowList(&descriptions)); |
| 69 EXPECT_EQ(1, descriptions.size()); | 70 EXPECT_EQ(1, descriptions.size()); |
| 70 WindowDescription desc = descriptions.front(); | 71 WindowDescription desc = descriptions.front(); |
| 71 EXPECT_EQ(window_picker.visible_window()->handle(), desc.id().id()); | 72 EXPECT_EQ(window_picker.visible_window()->handle(), desc.id().id()); |
| 72 TCHAR window_title[500]; | 73 TCHAR window_title[500]; |
| 73 GetWindowText(window_picker.visible_window()->handle(), window_title, | 74 GetWindowText(window_picker.visible_window()->handle(), window_title, |
| 74 ARRAY_SIZE(window_title)); | 75 arraysize(window_title)); |
| 75 EXPECT_EQ(0, wcscmp(window_title, kVisibleWindowTitle)); | 76 EXPECT_EQ(0, wcscmp(window_title, kVisibleWindowTitle)); |
| 76 } | 77 } |
| 77 | 78 |
| 78 TEST(Win32WindowPickerTest, TestIsVisible) { | 79 TEST(Win32WindowPickerTest, TestIsVisible) { |
| 79 Win32WindowPickerForTest window_picker; | 80 Win32WindowPickerForTest window_picker; |
| 80 HWND visible_id = window_picker.visible_window()->handle(); | 81 HWND visible_id = window_picker.visible_window()->handle(); |
| 81 HWND invisible_id = window_picker.invisible_window()->handle(); | 82 HWND invisible_id = window_picker.invisible_window()->handle(); |
| 82 EXPECT_TRUE(window_picker.IsVisible(WindowId(visible_id))); | 83 EXPECT_TRUE(window_picker.IsVisible(WindowId(visible_id))); |
| 83 EXPECT_FALSE(window_picker.IsVisible(WindowId(invisible_id))); | 84 EXPECT_FALSE(window_picker.IsVisible(WindowId(invisible_id))); |
| 84 } | 85 } |
| 85 | 86 |
| 86 TEST(Win32WindowPickerTest, TestMoveToFront) { | 87 TEST(Win32WindowPickerTest, TestMoveToFront) { |
| 87 Win32WindowPickerForTest window_picker; | 88 Win32WindowPickerForTest window_picker; |
| 88 HWND visible_id = window_picker.visible_window()->handle(); | 89 HWND visible_id = window_picker.visible_window()->handle(); |
| 89 HWND invisible_id = window_picker.invisible_window()->handle(); | 90 HWND invisible_id = window_picker.invisible_window()->handle(); |
| 90 | 91 |
| 91 // There are a number of condition where SetForegroundWindow might | 92 // There are a number of condition where SetForegroundWindow might |
| 92 // fail depending on the state of the calling process. To be on the | 93 // fail depending on the state of the calling process. To be on the |
| 93 // safe side we doesn't expect MoveToFront to return true, just test | 94 // safe side we doesn't expect MoveToFront to return true, just test |
| 94 // that we don't crash. | 95 // that we don't crash. |
| 95 window_picker.MoveToFront(WindowId(visible_id)); | 96 window_picker.MoveToFront(WindowId(visible_id)); |
| 96 window_picker.MoveToFront(WindowId(invisible_id)); | 97 window_picker.MoveToFront(WindowId(invisible_id)); |
| 97 } | 98 } |
| 98 | 99 |
| 99 } // namespace rtc | 100 } // namespace rtc |
| OLD | NEW |