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 <windows.h> | 5 #include <windows.h> |
6 #include <wininet.h> | 6 #include <wininet.h> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "base/win/scoped_handle.h" | 11 #include "base/win/scoped_handle.h" |
11 #include "chrome_frame/test/test_server.h" | 12 #include "chrome_frame/test/test_server.h" |
12 #include "net/base/cookie_monster.h" | 13 #include "net/base/cookie_monster.h" |
13 #include "net/base/host_resolver_proc.h" | 14 #include "net/base/host_resolver_proc.h" |
14 #include "net/disk_cache/disk_cache.h" | 15 #include "net/disk_cache/disk_cache.h" |
15 #include "net/http/http_auth_handler_factory.h" | 16 #include "net/http/http_auth_handler_factory.h" |
16 #include "net/http/http_cache.h" | 17 #include "net/http/http_cache.h" |
17 #include "net/http/http_network_session.h" | 18 #include "net/http/http_network_session.h" |
18 #include "net/proxy/proxy_service.h" | 19 #include "net/proxy/proxy_service.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 server.AddResponse(&person); | 139 server.AddResponse(&person); |
139 test_server::FileResponse file("/file", source_path().Append( | 140 test_server::FileResponse file("/file", source_path().Append( |
140 FILE_PATH_LITERAL("CFInstance.js"))); | 141 FILE_PATH_LITERAL("CFInstance.js"))); |
141 server.AddResponse(&file); | 142 server.AddResponse(&file); |
142 test_server::RedirectResponse redir("/goog", "http://www.google.com/"); | 143 test_server::RedirectResponse redir("/goog", "http://www.google.com/"); |
143 server.AddResponse(&redir); | 144 server.AddResponse(&redir); |
144 | 145 |
145 // We should never hit this, but it's our way to break out of the test if | 146 // We should never hit this, but it's our way to break out of the test if |
146 // things start hanging. | 147 // things start hanging. |
147 QuitMessageHit quit_msg(&loop); | 148 QuitMessageHit quit_msg(&loop); |
148 loop.PostDelayedTask(FROM_HERE, | 149 loop.PostDelayedTask(FROM_HERE, base::Bind(QuitMessageLoop, &quit_msg), |
149 NewRunnableFunction(QuitMessageLoop, &quit_msg), | |
150 10 * 1000); | 150 10 * 1000); |
151 | 151 |
152 UrlTaskChain quit_task("http://localhost:1337/quit", NULL); | 152 UrlTaskChain quit_task("http://localhost:1337/quit", NULL); |
153 UrlTaskChain fnf_task("http://localhost:1337/404", &quit_task); | 153 UrlTaskChain fnf_task("http://localhost:1337/404", &quit_task); |
154 UrlTaskChain person_task("http://localhost:1337/person", &fnf_task); | 154 UrlTaskChain person_task("http://localhost:1337/person", &fnf_task); |
155 UrlTaskChain file_task("http://localhost:1337/file", &person_task); | 155 UrlTaskChain file_task("http://localhost:1337/file", &person_task); |
156 UrlTaskChain goog_task("http://localhost:1337/goog", &file_task); | 156 UrlTaskChain goog_task("http://localhost:1337/goog", &file_task); |
157 | 157 |
158 DWORD tid = 0; | 158 DWORD tid = 0; |
159 base::win::ScopedHandle worker(::CreateThread( | 159 base::win::ScopedHandle worker(::CreateThread( |
160 NULL, 0, FetchUrl, &goog_task, 0, &tid)); | 160 NULL, 0, FetchUrl, &goog_task, 0, &tid)); |
161 loop.MessageLoop::Run(); | 161 loop.MessageLoop::Run(); |
162 | 162 |
163 EXPECT_FALSE(quit_msg.hit_); | 163 EXPECT_FALSE(quit_msg.hit_); |
164 if (!quit_msg.hit_) { | 164 if (!quit_msg.hit_) { |
165 EXPECT_EQ(::WaitForSingleObject(worker, 10 * 1000), WAIT_OBJECT_0); | 165 EXPECT_EQ(::WaitForSingleObject(worker, 10 * 1000), WAIT_OBJECT_0); |
166 | 166 |
167 EXPECT_EQ(person.accessed(), 1); | 167 EXPECT_EQ(person.accessed(), 1); |
168 EXPECT_EQ(file.accessed(), 1); | 168 EXPECT_EQ(file.accessed(), 1); |
169 EXPECT_EQ(redir.accessed(), 1); | 169 EXPECT_EQ(redir.accessed(), 1); |
170 | 170 |
171 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); | 171 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); |
172 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); | 172 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); |
173 EXPECT_TRUE(goog_task.response().find("<title>") != std::string::npos); | 173 EXPECT_TRUE(goog_task.response().find("<title>") != std::string::npos); |
174 } else { | 174 } else { |
175 ::TerminateThread(worker, ~0); | 175 ::TerminateThread(worker, ~0); |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |