OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 | 10 |
11 #ifndef WEBRTC_BASE_TESTUTILS_H__ | 11 #ifndef WEBRTC_BASE_TESTUTILS_H__ |
12 #define WEBRTC_BASE_TESTUTILS_H__ | 12 #define WEBRTC_BASE_TESTUTILS_H__ |
13 | 13 |
14 // Utilities for testing rtc infrastructure in unittests | 14 // Utilities for testing rtc infrastructure in unittests |
15 | 15 |
16 #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) | 16 #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) |
17 #include <X11/Xlib.h> | 17 #include <X11/Xlib.h> |
18 #include <X11/extensions/Xrandr.h> | 18 #include <X11/extensions/Xrandr.h> |
19 | 19 |
20 // X defines a few macros that stomp on types that gunit.h uses. | 20 // X defines a few macros that stomp on types that gunit.h uses. |
21 #undef None | 21 #undef None |
22 #undef Bool | 22 #undef Bool |
23 #endif | 23 #endif |
24 | 24 |
25 #include <algorithm> | 25 #include <algorithm> |
26 #include <map> | 26 #include <map> |
27 #include <vector> | 27 #include <vector> |
| 28 #include "webrtc/base/arraysize.h" |
28 #include "webrtc/base/asyncsocket.h" | 29 #include "webrtc/base/asyncsocket.h" |
29 #include "webrtc/base/common.h" | 30 #include "webrtc/base/common.h" |
30 #include "webrtc/base/gunit.h" | 31 #include "webrtc/base/gunit.h" |
31 #include "webrtc/base/nethelpers.h" | 32 #include "webrtc/base/nethelpers.h" |
32 #include "webrtc/base/pathutils.h" | 33 #include "webrtc/base/pathutils.h" |
33 #include "webrtc/base/stream.h" | 34 #include "webrtc/base/stream.h" |
34 #include "webrtc/base/stringencode.h" | 35 #include "webrtc/base/stringencode.h" |
35 #include "webrtc/base/stringutils.h" | 36 #include "webrtc/base/stringutils.h" |
36 #include "webrtc/base/thread.h" | 37 #include "webrtc/base/thread.h" |
37 | 38 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 send_buffer_.resize(new_size); | 351 send_buffer_.resize(new_size); |
351 } | 352 } |
352 | 353 |
353 void OnConnectEvent(AsyncSocket* socket) { | 354 void OnConnectEvent(AsyncSocket* socket) { |
354 if (!send_buffer_.empty()) { | 355 if (!send_buffer_.empty()) { |
355 Flush(); | 356 Flush(); |
356 } | 357 } |
357 } | 358 } |
358 void OnReadEvent(AsyncSocket* socket) { | 359 void OnReadEvent(AsyncSocket* socket) { |
359 char data[64 * 1024]; | 360 char data[64 * 1024]; |
360 int result = socket_->Recv(data, ARRAY_SIZE(data)); | 361 int result = socket_->Recv(data, arraysize(data)); |
361 if (result > 0) { | 362 if (result > 0) { |
362 recv_buffer_.insert(recv_buffer_.end(), data, data + result); | 363 recv_buffer_.insert(recv_buffer_.end(), data, data + result); |
363 } | 364 } |
364 } | 365 } |
365 void OnWriteEvent(AsyncSocket* socket) { | 366 void OnWriteEvent(AsyncSocket* socket) { |
366 if (!send_buffer_.empty()) { | 367 if (!send_buffer_.empty()) { |
367 Flush(); | 368 Flush(); |
368 } | 369 } |
369 } | 370 } |
370 void OnCloseEvent(AsyncSocket* socket, int error) { | 371 void OnCloseEvent(AsyncSocket* socket, int error) { |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 << minor_version; | 626 << minor_version; |
626 LOG(LS_WARNING) << "XRandr is not supported or is too old (pre 1.3)."; | 627 LOG(LS_WARNING) << "XRandr is not supported or is too old (pre 1.3)."; |
627 return false; | 628 return false; |
628 } | 629 } |
629 #endif | 630 #endif |
630 return true; | 631 return true; |
631 } | 632 } |
632 } // namespace testing | 633 } // namespace testing |
633 | 634 |
634 #endif // WEBRTC_BASE_TESTUTILS_H__ | 635 #endif // WEBRTC_BASE_TESTUTILS_H__ |
OLD | NEW |