Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: webrtc/base/testutils.h

Issue 1920043002: Replace scoped_ptr with unique_ptr in webrtc/base/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/testechoserver.h ('k') | webrtc/base/thread_checker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory>
27 #include <vector> 28 #include <vector>
28 #include "webrtc/base/arraysize.h" 29 #include "webrtc/base/arraysize.h"
29 #include "webrtc/base/asyncsocket.h" 30 #include "webrtc/base/asyncsocket.h"
30 #include "webrtc/base/common.h" 31 #include "webrtc/base/common.h"
31 #include "webrtc/base/gunit.h" 32 #include "webrtc/base/gunit.h"
32 #include "webrtc/base/nethelpers.h" 33 #include "webrtc/base/nethelpers.h"
33 #include "webrtc/base/pathutils.h" 34 #include "webrtc/base/pathutils.h"
34 #include "webrtc/base/stream.h" 35 #include "webrtc/base/stream.h"
35 #include "webrtc/base/stringencode.h" 36 #include "webrtc/base/stringencode.h"
36 #include "webrtc/base/stringutils.h" 37 #include "webrtc/base/stringutils.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 365 }
365 } 366 }
366 void OnWriteEvent(AsyncSocket* socket) { 367 void OnWriteEvent(AsyncSocket* socket) {
367 if (!send_buffer_.empty()) { 368 if (!send_buffer_.empty()) {
368 Flush(); 369 Flush();
369 } 370 }
370 } 371 }
371 void OnCloseEvent(AsyncSocket* socket, int error) { 372 void OnCloseEvent(AsyncSocket* socket, int error) {
372 } 373 }
373 374
374 scoped_ptr<AsyncSocket> socket_; 375 std::unique_ptr<AsyncSocket> socket_;
375 Buffer send_buffer_, recv_buffer_; 376 Buffer send_buffer_, recv_buffer_;
376 }; 377 };
377 378
378 /////////////////////////////////////////////////////////////////////////////// 379 ///////////////////////////////////////////////////////////////////////////////
379 // SocketTestServer 380 // SocketTestServer
380 // Creates a simulated server for testing. Works on real and virtual networks. 381 // Creates a simulated server for testing. Works on real and virtual networks.
381 /////////////////////////////////////////////////////////////////////////////// 382 ///////////////////////////////////////////////////////////////////////////////
382 383
383 class SocketTestServer : public sigslot::has_slots<> { 384 class SocketTestServer : public sigslot::has_slots<> {
384 public: 385 public:
(...skipping 22 matching lines...) Expand all
407 408
408 private: 409 private:
409 void OnReadEvent(AsyncSocket* socket) { 410 void OnReadEvent(AsyncSocket* socket) {
410 AsyncSocket* accepted = 411 AsyncSocket* accepted =
411 static_cast<AsyncSocket*>(socket_->Accept(NULL)); 412 static_cast<AsyncSocket*>(socket_->Accept(NULL));
412 if (!accepted) 413 if (!accepted)
413 return; 414 return;
414 clients_.push_back(new SocketTestClient(accepted)); 415 clients_.push_back(new SocketTestClient(accepted));
415 } 416 }
416 417
417 scoped_ptr<AsyncSocket> socket_; 418 std::unique_ptr<AsyncSocket> socket_;
418 std::vector<SocketTestClient*> clients_; 419 std::vector<SocketTestClient*> clients_;
419 }; 420 };
420 421
421 /////////////////////////////////////////////////////////////////////////////// 422 ///////////////////////////////////////////////////////////////////////////////
422 // Generic Utilities 423 // Generic Utilities
423 /////////////////////////////////////////////////////////////////////////////// 424 ///////////////////////////////////////////////////////////////////////////////
424 425
425 inline bool ReadFile(const char* filename, std::string* contents) { 426 inline bool ReadFile(const char* filename, std::string* contents) {
426 FILE* fp = fopen(filename, "rb"); 427 FILE* fp = fopen(filename, "rb");
427 if (!fp) 428 if (!fp)
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 << minor_version; 627 << minor_version;
627 LOG(LS_WARNING) << "XRandr is not supported or is too old (pre 1.3)."; 628 LOG(LS_WARNING) << "XRandr is not supported or is too old (pre 1.3).";
628 return false; 629 return false;
629 } 630 }
630 #endif 631 #endif
631 return true; 632 return true;
632 } 633 }
633 } // namespace testing 634 } // namespace testing
634 635
635 #endif // WEBRTC_BASE_TESTUTILS_H__ 636 #endif // WEBRTC_BASE_TESTUTILS_H__
OLDNEW
« no previous file with comments | « webrtc/base/testechoserver.h ('k') | webrtc/base/thread_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698