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

Side by Side Diff: base/message_loop_unittest.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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 | « base/message_loop_proxy_impl.cc ('k') | base/metrics/field_trial_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 // 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 <vector> 5 #include <vector>
6 6
7 #include "base/eintr_wrapper.h" 7 #include "base/eintr_wrapper.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/platform_thread.h" 10 #include "base/platform_thread.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 private: 88 private:
89 friend class base::RefCounted<QuitMsgLoop>; 89 friend class base::RefCounted<QuitMsgLoop>;
90 90
91 ~QuitMsgLoop() {} 91 ~QuitMsgLoop() {}
92 }; 92 };
93 93
94 void RunTest_PostTask(MessageLoop::Type message_loop_type) { 94 void RunTest_PostTask(MessageLoop::Type message_loop_type) {
95 MessageLoop loop(message_loop_type); 95 MessageLoop loop(message_loop_type);
96 96
97 // Add tests to message loop 97 // Add tests to message loop
98 scoped_refptr<Foo> foo = new Foo(); 98 scoped_refptr<Foo> foo(new Foo());
99 std::string a("a"), b("b"), c("c"), d("d"); 99 std::string a("a"), b("b"), c("c"), d("d");
100 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 100 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
101 foo.get(), &Foo::Test0)); 101 foo.get(), &Foo::Test0));
102 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 102 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
103 foo.get(), &Foo::Test1ConstRef, a)); 103 foo.get(), &Foo::Test1ConstRef, a));
104 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 104 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
105 foo.get(), &Foo::Test1Ptr, &b)); 105 foo.get(), &Foo::Test1Ptr, &b));
106 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 106 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
107 foo.get(), &Foo::Test1Int, 100)); 107 foo.get(), &Foo::Test1Int, 100));
108 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 108 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
109 foo.get(), &Foo::Test2Ptr, &a, &c)); 109 foo.get(), &Foo::Test2Ptr, &a, &c));
110 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 110 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
111 foo.get(), &Foo::Test2Mixed, a, &d)); 111 foo.get(), &Foo::Test2Mixed, a, &d));
112 112
113 // After all tests, post a message that will shut down the message loop 113 // After all tests, post a message that will shut down the message loop
114 scoped_refptr<QuitMsgLoop> quit = new QuitMsgLoop(); 114 scoped_refptr<QuitMsgLoop> quit(new QuitMsgLoop());
115 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 115 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
116 quit.get(), &QuitMsgLoop::QuitNow)); 116 quit.get(), &QuitMsgLoop::QuitNow));
117 117
118 // Now kick things off 118 // Now kick things off
119 MessageLoop::current()->Run(); 119 MessageLoop::current()->Run();
120 120
121 EXPECT_EQ(foo->test_count(), 105); 121 EXPECT_EQ(foo->test_count(), 105);
122 EXPECT_EQ(foo->result(), "abacad"); 122 EXPECT_EQ(foo->result(), "abacad");
123 } 123 }
124 124
125 void RunTest_PostTask_SEH(MessageLoop::Type message_loop_type) { 125 void RunTest_PostTask_SEH(MessageLoop::Type message_loop_type) {
126 MessageLoop loop(message_loop_type); 126 MessageLoop loop(message_loop_type);
127 127
128 // Add tests to message loop 128 // Add tests to message loop
129 scoped_refptr<Foo> foo = new Foo(); 129 scoped_refptr<Foo> foo(new Foo());
130 std::string a("a"), b("b"), c("c"), d("d"); 130 std::string a("a"), b("b"), c("c"), d("d");
131 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 131 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
132 foo.get(), &Foo::Test0)); 132 foo.get(), &Foo::Test0));
133 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 133 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
134 foo.get(), &Foo::Test1ConstRef, a)); 134 foo.get(), &Foo::Test1ConstRef, a));
135 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 135 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
136 foo.get(), &Foo::Test1Ptr, &b)); 136 foo.get(), &Foo::Test1Ptr, &b));
137 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 137 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
138 foo.get(), &Foo::Test1Int, 100)); 138 foo.get(), &Foo::Test1Int, 100));
139 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 139 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
140 foo.get(), &Foo::Test2Ptr, &a, &c)); 140 foo.get(), &Foo::Test2Ptr, &a, &c));
141 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 141 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
142 foo.get(), &Foo::Test2Mixed, a, &d)); 142 foo.get(), &Foo::Test2Mixed, a, &d));
143 143
144 // After all tests, post a message that will shut down the message loop 144 // After all tests, post a message that will shut down the message loop
145 scoped_refptr<QuitMsgLoop> quit = new QuitMsgLoop(); 145 scoped_refptr<QuitMsgLoop> quit(new QuitMsgLoop());
146 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 146 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
147 quit.get(), &QuitMsgLoop::QuitNow)); 147 quit.get(), &QuitMsgLoop::QuitNow));
148 148
149 // Now kick things off with the SEH block active. 149 // Now kick things off with the SEH block active.
150 MessageLoop::current()->set_exception_restoration(true); 150 MessageLoop::current()->set_exception_restoration(true);
151 MessageLoop::current()->Run(); 151 MessageLoop::current()->Run();
152 MessageLoop::current()->set_exception_restoration(false); 152 MessageLoop::current()->set_exception_restoration(false);
153 153
154 EXPECT_EQ(foo->test_count(), 105); 154 EXPECT_EQ(foo->test_count(), 105);
155 EXPECT_EQ(foo->result(), "abacad"); 155 EXPECT_EQ(foo->result(), "abacad");
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 } 1640 }
1641 if (HANDLE_EINTR(close(pipefds[0])) < 0) 1641 if (HANDLE_EINTR(close(pipefds[0])) < 0)
1642 PLOG(ERROR) << "close"; 1642 PLOG(ERROR) << "close";
1643 if (HANDLE_EINTR(close(pipefds[1])) < 0) 1643 if (HANDLE_EINTR(close(pipefds[1])) < 0)
1644 PLOG(ERROR) << "close"; 1644 PLOG(ERROR) << "close";
1645 } 1645 }
1646 1646
1647 } // namespace 1647 } // namespace
1648 1648
1649 #endif // defined(OS_POSIX) 1649 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « base/message_loop_proxy_impl.cc ('k') | base/metrics/field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698