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

Side by Side Diff: remoting/protocol/monitored_video_stub_unittest.cc

Issue 264963007: Fix MonitoredVideoStubTest failure in memory runs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix MonitoredVideoStubTest failure in memory runs Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/valgrind/gtest_exclude/remoting_unittests.gtest.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "remoting/protocol/monitored_video_stub.h" 5 #include "remoting/protocol/monitored_video_stub.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
11 #include "remoting/protocol/protocol_mock_objects.h" 11 #include "remoting/protocol/protocol_mock_objects.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using ::testing::_; 15 using ::testing::_;
16 using ::testing::AnyNumber; 16 using ::testing::AnyNumber;
17 using ::testing::AtMost;
17 using ::testing::InvokeWithoutArgs; 18 using ::testing::InvokeWithoutArgs;
18 19
19 namespace remoting { 20 namespace remoting {
20 namespace protocol { 21 namespace protocol {
21 22
22 static const int64 kTestOverrideDelayMilliseconds = 1; 23 static const int64 kTestOverrideDelayMilliseconds = 1;
23 24
24 class MonitoredVideoStubTest : public testing::Test { 25 class MonitoredVideoStubTest : public testing::Test {
25 protected: 26 protected:
26 virtual void SetUp() OVERRIDE { 27 virtual void SetUp() OVERRIDE {
(...skipping 12 matching lines...) Expand all
39 base::MessageLoop message_loop_; 40 base::MessageLoop message_loop_;
40 MockVideoStub video_stub_; 41 MockVideoStub video_stub_;
41 42
42 scoped_ptr<MonitoredVideoStub> monitor_; 43 scoped_ptr<MonitoredVideoStub> monitor_;
43 scoped_ptr<VideoPacket> packet_; 44 scoped_ptr<VideoPacket> packet_;
44 base::OneShotTimer<MonitoredVideoStubTest> timer_end_test_; 45 base::OneShotTimer<MonitoredVideoStubTest> timer_end_test_;
45 }; 46 };
46 47
47 TEST_F(MonitoredVideoStubTest, OnChannelConnected) { 48 TEST_F(MonitoredVideoStubTest, OnChannelConnected) {
48 EXPECT_CALL(*this, OnVideoChannelStatus(true)); 49 EXPECT_CALL(*this, OnVideoChannelStatus(true));
50 // On slow machines, the connectivity check timer may fires before the test
Jamie 2014/05/02 01:06:32 s/fires/fire/, here and below.
kelvinp 2014/05/02 01:11:14 Done.
51 // finishes, so we expect to see at most one transition to not ready.
52 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(AtMost(1));
53
49 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); 54 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure());
50 base::RunLoop().RunUntilIdle(); 55 base::RunLoop().RunUntilIdle();
51 } 56 }
52 57
53 TEST_F(MonitoredVideoStubTest, OnChannelDisconnected) { 58 TEST_F(MonitoredVideoStubTest, OnChannelDisconnected) {
54 EXPECT_CALL(*this, OnVideoChannelStatus(true)); 59 EXPECT_CALL(*this, OnVideoChannelStatus(true));
55 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); 60 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure());
56 61
57 EXPECT_CALL(*this, OnVideoChannelStatus(false)).WillOnce( 62 EXPECT_CALL(*this, OnVideoChannelStatus(false)).WillOnce(
58 InvokeWithoutArgs( 63 InvokeWithoutArgs(
59 &message_loop_, 64 &message_loop_,
60 &base::MessageLoop::Quit)); 65 &base::MessageLoop::Quit));
61 message_loop_.Run(); 66 message_loop_.Run();
62 } 67 }
63 68
64 TEST_F(MonitoredVideoStubTest, OnChannelStayConnected) { 69 TEST_F(MonitoredVideoStubTest, OnChannelStayConnected) {
65 // Verify no extra connected events are fired when packets are received 70 // Verify no extra connected events are fired when packets are received
66 // frequently 71 // frequently
67 EXPECT_CALL(*this, OnVideoChannelStatus(_)).Times(1); 72 EXPECT_CALL(*this, OnVideoChannelStatus(true));
73 // On slow machines, the connectivity check timer may fires before the test
74 // finishes, so we expect to see at most one transition to not ready.
75 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(AtMost(1));
68 76
69 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); 77 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure());
70 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); 78 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure());
71 base::RunLoop().RunUntilIdle(); 79 base::RunLoop().RunUntilIdle();
72 } 80 }
73 81
74 TEST_F(MonitoredVideoStubTest, OnChannelStayDisconnected) { 82 TEST_F(MonitoredVideoStubTest, OnChannelStayDisconnected) {
75 // Verify no extra disconnected events are fired. 83 // Verify no extra disconnected events are fired.
76 EXPECT_CALL(*this, OnVideoChannelStatus(true)).Times(1); 84 EXPECT_CALL(*this, OnVideoChannelStatus(true)).Times(1);
77 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(1); 85 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(1);
78 86
79 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); 87 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure());
80 88
81 message_loop_.PostDelayedTask( 89 message_loop_.PostDelayedTask(
82 FROM_HERE, 90 FROM_HERE,
83 base::MessageLoop::QuitClosure(), 91 base::MessageLoop::QuitClosure(),
84 // The delay should be much greater than |kTestOverrideDelayMilliseconds|. 92 // The delay should be much greater than |kTestOverrideDelayMilliseconds|.
85 TestTimeouts::tiny_timeout()); 93 TestTimeouts::tiny_timeout());
86 message_loop_.Run(); 94 message_loop_.Run();
87 } 95 }
88 96
89 } // namespace protocol 97 } // namespace protocol
90 } // namespace remoting 98 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/gtest_exclude/remoting_unittests.gtest.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698