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

Side by Side Diff: extensions/browser/api/cast_channel/keep_alive_delegate_unittest.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/api/cast_channel/keep_alive_delegate.h" 5 #include "extensions/browser/api/cast_channel/keep_alive_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 12 #include "base/run_loop.h"
12 #include "base/test/simple_test_clock.h" 13 #include "base/test/simple_test_clock.h"
13 #include "base/timer/mock_timer.h" 14 #include "base/timer/mock_timer.h"
14 #include "extensions/browser/api/cast_channel/cast_test_util.h" 15 #include "extensions/browser/api/cast_channel/cast_test_util.h"
15 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using testing::_; 20 using testing::_;
(...skipping 27 matching lines...) Expand all
47 }; 48 };
48 49
49 class KeepAliveDelegateTest : public testing::Test { 50 class KeepAliveDelegateTest : public testing::Test {
50 public: 51 public:
51 KeepAliveDelegateTest() {} 52 KeepAliveDelegateTest() {}
52 ~KeepAliveDelegateTest() override {} 53 ~KeepAliveDelegateTest() override {}
53 54
54 protected: 55 protected:
55 void SetUp() override { 56 void SetUp() override {
56 inner_delegate_ = new MockCastTransportDelegate; 57 inner_delegate_ = new MockCastTransportDelegate;
57 logger_ = new Logger(scoped_ptr<base::Clock>(new base::SimpleTestClock), 58 logger_ = new Logger(
58 base::Time()); 59 std::unique_ptr<base::Clock>(new base::SimpleTestClock), base::Time());
59 keep_alive_.reset(new KeepAliveDelegate( 60 keep_alive_.reset(new KeepAliveDelegate(
60 &socket_, logger_, make_scoped_ptr(inner_delegate_), 61 &socket_, logger_, base::WrapUnique(inner_delegate_),
61 base::TimeDelta::FromMilliseconds(kTestPingTimeoutMillis), 62 base::TimeDelta::FromMilliseconds(kTestPingTimeoutMillis),
62 base::TimeDelta::FromMilliseconds(kTestLivenessTimeoutMillis))); 63 base::TimeDelta::FromMilliseconds(kTestLivenessTimeoutMillis)));
63 liveness_timer_ = new MockTimerWithMonitoredReset(true, false); 64 liveness_timer_ = new MockTimerWithMonitoredReset(true, false);
64 ping_timer_ = new MockTimerWithMonitoredReset(true, false); 65 ping_timer_ = new MockTimerWithMonitoredReset(true, false);
65 EXPECT_CALL(*liveness_timer_, Stop()).Times(0); 66 EXPECT_CALL(*liveness_timer_, Stop()).Times(0);
66 EXPECT_CALL(*ping_timer_, Stop()).Times(0); 67 EXPECT_CALL(*ping_timer_, Stop()).Times(0);
67 keep_alive_->SetTimersForTest(make_scoped_ptr(ping_timer_), 68 keep_alive_->SetTimersForTest(base::WrapUnique(ping_timer_),
68 make_scoped_ptr(liveness_timer_)); 69 base::WrapUnique(liveness_timer_));
69 } 70 }
70 71
71 // Runs all pending tasks in the message loop. 72 // Runs all pending tasks in the message loop.
72 void RunPendingTasks() { 73 void RunPendingTasks() {
73 base::RunLoop run_loop; 74 base::RunLoop run_loop;
74 run_loop.RunUntilIdle(); 75 run_loop.RunUntilIdle();
75 } 76 }
76 77
77 base::MessageLoop message_loop_; 78 base::MessageLoop message_loop_;
78 MockCastSocket socket_; 79 MockCastSocket socket_;
79 scoped_ptr<KeepAliveDelegate> keep_alive_; 80 std::unique_ptr<KeepAliveDelegate> keep_alive_;
80 scoped_refptr<Logger> logger_; 81 scoped_refptr<Logger> logger_;
81 MockCastTransportDelegate* inner_delegate_; 82 MockCastTransportDelegate* inner_delegate_;
82 MockTimerWithMonitoredReset* liveness_timer_; 83 MockTimerWithMonitoredReset* liveness_timer_;
83 MockTimerWithMonitoredReset* ping_timer_; 84 MockTimerWithMonitoredReset* ping_timer_;
84 85
85 private: 86 private:
86 DISALLOW_COPY_AND_ASSIGN(KeepAliveDelegateTest); 87 DISALLOW_COPY_AND_ASSIGN(KeepAliveDelegateTest);
87 }; 88 };
88 89
89 TEST_F(KeepAliveDelegateTest, TestErrorHandledBeforeStarting) { 90 TEST_F(KeepAliveDelegateTest, TestErrorHandledBeforeStarting) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 161
161 keep_alive_->Start(); 162 keep_alive_->Start();
162 keep_alive_->OnMessage(other_message); 163 keep_alive_->OnMessage(other_message);
163 RunPendingTasks(); 164 RunPendingTasks();
164 } 165 }
165 166
166 } // namespace 167 } // namespace
167 } // namespace cast_channel 168 } // namespace cast_channel
168 } // namespace api 169 } // namespace api
169 } // namespace extensions 170 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/keep_alive_delegate.cc ('k') | extensions/browser/api/cast_channel/logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698