OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/net/connection_tester.h" | 5 #include "chrome/browser/net/connection_tester.h" |
6 | 6 |
7 #include "chrome/test/base/testing_pref_service.h" | 7 #include "chrome/test/base/testing_pref_service.h" |
8 #include "content/test/test_browser_thread.h" | 8 #include "content/test/test_browser_thread.h" |
9 #include "net/base/cert_verifier.h" | 9 #include "net/base/cert_verifier.h" |
10 #include "net/base/cookie_monster.h" | 10 #include "net/base/cookie_monster.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 TEST_F(ConnectionTesterTest, DeleteWhileInProgress) { | 169 TEST_F(ConnectionTesterTest, DeleteWhileInProgress) { |
170 ASSERT_TRUE(test_server_.Start()); | 170 ASSERT_TRUE(test_server_.Start()); |
171 | 171 |
172 scoped_ptr<ConnectionTester> tester( | 172 scoped_ptr<ConnectionTester> tester( |
173 new ConnectionTester(&test_delegate_, proxy_script_fetcher_context_)); | 173 new ConnectionTester(&test_delegate_, proxy_script_fetcher_context_)); |
174 | 174 |
175 // Start the test suite on URL "echoall". | 175 // Start the test suite on URL "echoall". |
176 // TODO(eroman): Is this URL right? | 176 // TODO(eroman): Is this URL right? |
177 tester->RunAllTests(test_server_.GetURL("echoall")); | 177 tester->RunAllTests(test_server_.GetURL("echoall")); |
178 | 178 |
179 MessageLoop::current()->RunAllPending(); | 179 // Don't run the message loop at all. Otherwise the experiment's request may |
| 180 // complete and post a task to run the next experiment before we quit the |
| 181 // message loop. |
180 | 182 |
181 EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count()); | 183 EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count()); |
182 EXPECT_EQ(1, test_delegate_.start_connection_test_experiment_count()); | 184 EXPECT_EQ(1, test_delegate_.start_connection_test_experiment_count()); |
183 EXPECT_EQ(0, test_delegate_.completed_connection_test_experiment_count()); | 185 EXPECT_EQ(0, test_delegate_.completed_connection_test_experiment_count()); |
184 EXPECT_EQ(0, test_delegate_.completed_connection_test_suite_count()); | 186 EXPECT_EQ(0, test_delegate_.completed_connection_test_suite_count()); |
185 | 187 |
186 // Delete the ConnectionTester while it is in progress. | 188 // Delete the ConnectionTester while it is in progress. |
187 tester.reset(); | 189 tester.reset(); |
188 | 190 |
189 // Drain the tasks on the message loop. | 191 // Drain the tasks on the message loop. |
190 // | 192 // |
191 // Note that we cannot simply stop the message loop, since that will delete | 193 // Note that we cannot simply stop the message loop, since that will delete |
192 // any pending tasks instead of running them. This causes a problem with | 194 // any pending tasks instead of running them. This causes a problem with |
193 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer | 195 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer |
194 // |backup_task| that it will try to deref during the destructor, but | 196 // |backup_task| that it will try to deref during the destructor, but |
195 // depending on the order that pending tasks were deleted in, it might | 197 // depending on the order that pending tasks were deleted in, it might |
196 // already be invalid! See http://crbug.com/43291. | 198 // already be invalid! See http://crbug.com/43291. |
197 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 199 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
198 MessageLoop::current()->Run(); | 200 MessageLoop::current()->Run(); |
199 } | 201 } |
200 | 202 |
201 } // namespace | 203 } // namespace |
OLD | NEW |