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

Side by Side Diff: remoting/jingle_glue/jingle_client_unittest.cc

Issue 5852001: Fix the last scoped_refptr misuses in NewRunnableMethod. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 | « chrome/browser/download/download_item.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/waitable_event.h" 5 #include "base/waitable_event.h"
6 #include "remoting/jingle_glue/jingle_client.h" 6 #include "remoting/jingle_glue/jingle_client.h"
7 #include "remoting/jingle_glue/jingle_thread.h" 7 #include "remoting/jingle_glue/jingle_thread.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 }; 50 };
51 51
52 TEST_F(JingleClientTest, OnStateChanged) { 52 TEST_F(JingleClientTest, OnStateChanged) {
53 EXPECT_CALL(callback_, OnStateChange(_, JingleClient::CONNECTING)) 53 EXPECT_CALL(callback_, OnStateChange(_, JingleClient::CONNECTING))
54 .Times(1); 54 .Times(1);
55 55
56 thread_.Start(); 56 thread_.Start();
57 57
58 base::WaitableEvent state_changed_event(true, false); 58 base::WaitableEvent state_changed_event(true, false);
59 thread_.message_loop()->PostTask(FROM_HERE, NewRunnableFunction( 59 thread_.message_loop()->PostTask(FROM_HERE, NewRunnableFunction(
60 &JingleClientTest::ChangeState, client_.get(), 60 &JingleClientTest::ChangeState, client_,
61 buzz::XmppEngine::STATE_OPENING, &state_changed_event)); 61 buzz::XmppEngine::STATE_OPENING, &state_changed_event));
62 state_changed_event.Wait(); 62 state_changed_event.Wait();
63 63
64 client_->Close(); 64 client_->Close();
65 65
66 thread_.Stop(); 66 thread_.Stop();
67 } 67 }
68 68
69 TEST_F(JingleClientTest, Close) { 69 TEST_F(JingleClientTest, Close) {
70 EXPECT_CALL(callback_, OnStateChange(_, _)) 70 EXPECT_CALL(callback_, OnStateChange(_, _))
71 .Times(0); 71 .Times(0);
72 thread_.Start(); 72 thread_.Start();
73 client_->Close(); 73 client_->Close();
74 // Verify that the channel doesn't call callback anymore. 74 // Verify that the channel doesn't call callback anymore.
75 thread_.message_loop()->PostTask(FROM_HERE, NewRunnableFunction( 75 thread_.message_loop()->PostTask(FROM_HERE, NewRunnableFunction(
76 &JingleClientTest::ChangeState, client_.get(), 76 &JingleClientTest::ChangeState, client_,
77 buzz::XmppEngine::STATE_OPENING, 77 buzz::XmppEngine::STATE_OPENING,
78 static_cast<base::WaitableEvent*>(NULL))); 78 static_cast<base::WaitableEvent*>(NULL)));
79 thread_.Stop(); 79 thread_.Stop();
80 } 80 }
81 81
82 TEST_F(JingleClientTest, ClosedTask) { 82 TEST_F(JingleClientTest, ClosedTask) {
83 thread_.Start(); 83 thread_.Start();
84 bool closed = false; 84 bool closed = false;
85 client_->Close(NewRunnableFunction(&JingleClientTest::OnClosed, 85 client_->Close(NewRunnableFunction(&JingleClientTest::OnClosed,
86 &closed)); 86 &closed));
87 thread_.Stop(); 87 thread_.Stop();
88 EXPECT_TRUE(closed); 88 EXPECT_TRUE(closed);
89 } 89 }
90 90
91 TEST_F(JingleClientTest, DoubleClose) { 91 TEST_F(JingleClientTest, DoubleClose) {
92 thread_.Start(); 92 thread_.Start();
93 bool closed1 = false; 93 bool closed1 = false;
94 client_->Close(NewRunnableFunction(&JingleClientTest::OnClosed, 94 client_->Close(NewRunnableFunction(&JingleClientTest::OnClosed,
95 &closed1)); 95 &closed1));
96 bool closed2 = false; 96 bool closed2 = false;
97 client_->Close(NewRunnableFunction(&JingleClientTest::OnClosed, 97 client_->Close(NewRunnableFunction(&JingleClientTest::OnClosed,
98 &closed2)); 98 &closed2));
99 thread_.Stop(); 99 thread_.Stop();
100 EXPECT_TRUE(closed1 && closed2); 100 EXPECT_TRUE(closed1 && closed2);
101 } 101 }
102 102
103 } // namespace remoting 103 } // namespace remoting
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698