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

Side by Side Diff: chrome/browser/net/connection_tester_unittest.cc

Issue 3034038: GTTF: Move more test server code from net/url_request/url_request_unittest.h (Closed)
Patch Set: hopefully final Created 10 years, 4 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
« no previous file with comments | « chrome/browser/login_prompt_uitest.cc ('k') | chrome/browser/net/cookie_policy_browsertest.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 "chrome/browser/net/connection_tester.h" 5 #include "chrome/browser/net/connection_tester.h"
6 6
7 #include "net/base/mock_host_resolver.h" 7 #include "net/base/mock_host_resolver.h"
8 #include "net/url_request/url_request_unittest.h" 8 #include "net/test/test_server.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
11 11
12 namespace { 12 namespace {
13 13
14 // This is a testing delegate which simply counts how many times each of 14 // This is a testing delegate which simply counts how many times each of
15 // the delegate's methods were invoked. 15 // the delegate's methods were invoked.
16 class ConnectionTesterDelegate : public ConnectionTester::Delegate { 16 class ConnectionTesterDelegate : public ConnectionTester::Delegate {
17 public: 17 public:
18 ConnectionTesterDelegate() 18 ConnectionTesterDelegate()
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 scoped_host_resolver_proc_.Init(catchall_resolver); 80 scoped_host_resolver_proc_.Init(catchall_resolver);
81 } 81 }
82 82
83 protected: 83 protected:
84 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; 84 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_;
85 ConnectionTesterDelegate test_delegate_; 85 ConnectionTesterDelegate test_delegate_;
86 MessageLoop message_loop_; 86 MessageLoop message_loop_;
87 }; 87 };
88 88
89 TEST_F(ConnectionTesterTest, RunAllTests) { 89 TEST_F(ConnectionTesterTest, RunAllTests) {
90 scoped_refptr<HTTPTestServer> server = 90 scoped_refptr<net::HTTPTestServer> server =
91 HTTPTestServer::CreateServer(L"net/data/url_request_unittest/"); 91 net::HTTPTestServer::CreateServer(L"net/data/url_request_unittest/");
92 92
93 ConnectionTester tester(&test_delegate_); 93 ConnectionTester tester(&test_delegate_);
94 94
95 // Start the test suite on URL "echoall". 95 // Start the test suite on URL "echoall".
96 // TODO(eroman): Is this URL right? 96 // TODO(eroman): Is this URL right?
97 GURL url = server->TestServerPage("echoall"); 97 GURL url = server->TestServerPage("echoall");
98 tester.RunAllTests(url); 98 tester.RunAllTests(url);
99 99
100 // Wait for all the tests to complete. 100 // Wait for all the tests to complete.
101 MessageLoop::current()->Run(); 101 MessageLoop::current()->Run();
102 102
103 const int kNumExperiments = 103 const int kNumExperiments =
104 ConnectionTester::PROXY_EXPERIMENT_COUNT * 104 ConnectionTester::PROXY_EXPERIMENT_COUNT *
105 ConnectionTester::HOST_RESOLVER_EXPERIMENT_COUNT; 105 ConnectionTester::HOST_RESOLVER_EXPERIMENT_COUNT;
106 106
107 EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count()); 107 EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count());
108 EXPECT_EQ(kNumExperiments, 108 EXPECT_EQ(kNumExperiments,
109 test_delegate_.start_connection_test_experiment_count()); 109 test_delegate_.start_connection_test_experiment_count());
110 EXPECT_EQ(kNumExperiments, 110 EXPECT_EQ(kNumExperiments,
111 test_delegate_.completed_connection_test_experiment_count()); 111 test_delegate_.completed_connection_test_experiment_count());
112 EXPECT_EQ(1, test_delegate_.completed_connection_test_suite_count()); 112 EXPECT_EQ(1, test_delegate_.completed_connection_test_suite_count());
113 } 113 }
114 114
115 TEST_F(ConnectionTesterTest, DeleteWhileInProgress) { 115 TEST_F(ConnectionTesterTest, DeleteWhileInProgress) {
116 scoped_refptr<HTTPTestServer> server = 116 scoped_refptr<net::HTTPTestServer> server =
117 HTTPTestServer::CreateServer(L"net/data/url_request_unittest/"); 117 net::HTTPTestServer::CreateServer(L"net/data/url_request_unittest/");
118 118
119 scoped_ptr<ConnectionTester> tester(new ConnectionTester(&test_delegate_)); 119 scoped_ptr<ConnectionTester> tester(new ConnectionTester(&test_delegate_));
120 120
121 // Start the test suite on URL "echoall". 121 // Start the test suite on URL "echoall".
122 // TODO(eroman): Is this URL right? 122 // TODO(eroman): Is this URL right?
123 GURL url = server->TestServerPage("echoall"); 123 GURL url = server->TestServerPage("echoall");
124 tester->RunAllTests(url); 124 tester->RunAllTests(url);
125 125
126 MessageLoop::current()->RunAllPending(); 126 MessageLoop::current()->RunAllPending();
127 127
(...skipping 12 matching lines...) Expand all
140 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer 140 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer
141 // |backup_task| that it will try to deref during the destructor, but 141 // |backup_task| that it will try to deref during the destructor, but
142 // depending on the order that pending tasks were deleted in, it might 142 // depending on the order that pending tasks were deleted in, it might
143 // already be invalid! See http://crbug.com/43291. 143 // already be invalid! See http://crbug.com/43291.
144 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 144 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
145 MessageLoop::current()->Run(); 145 MessageLoop::current()->Run();
146 } 146 }
147 147
148 } // namespace 148 } // namespace
149 149
OLDNEW
« no previous file with comments | « chrome/browser/login_prompt_uitest.cc ('k') | chrome/browser/net/cookie_policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698