| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ | 5 #ifndef WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ |
| 6 #define WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ | 6 #define WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ |
| 7 | 7 |
| 8 #include "webkit/glue/resource_loader_bridge.h" | 8 #include "webkit/glue/resource_loader_bridge.h" |
| 9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
| 10 #include "net/url_request/url_request_unittest.h" | 10 #include "net/url_request/url_request_unittest.h" |
| 11 | 11 |
| 12 using webkit_glue::ResourceLoaderBridge; | 12 using webkit_glue::ResourceLoaderBridge; |
| 13 | 13 |
| 14 // We need to use ResourceLoaderBridge to communicate with the testserver | 14 // We need to use ResourceLoaderBridge to communicate with the testserver |
| 15 // instead of using URLRequest directly because URLRequests need to be run on | 15 // instead of using URLRequest directly because URLRequests need to be run on |
| 16 // the test_shell's IO thread. | 16 // the test_shell's IO thread. |
| 17 class UnittestTestServer : public HTTPTestServer { | 17 class UnittestTestServer : public TestServer { |
| 18 protected: | 18 public: |
| 19 UnittestTestServer() { | 19 UnittestTestServer() : TestServer(TestServer::ManualInit()) { |
| 20 Init("localhost", 1337, L"webkit/data", std::wstring()); |
| 20 } | 21 } |
| 21 | 22 |
| 22 public: | 23 ~UnittestTestServer() { |
| 23 static UnittestTestServer* CreateServer() { | 24 Shutdown(); |
| 24 UnittestTestServer* test_server = new UnittestTestServer(); | |
| 25 if (!test_server->Init("localhost", 1337, L"webkit/data")) { | |
| 26 delete test_server; | |
| 27 return NULL; | |
| 28 } | |
| 29 return test_server; | |
| 30 } | |
| 31 | |
| 32 virtual ~UnittestTestServer() { | |
| 33 } | 25 } |
| 34 | 26 |
| 35 virtual bool MakeGETRequest(const std::string& page_name) { | 27 virtual bool MakeGETRequest(const std::string& page_name) { |
| 36 GURL url(TestServerPage(page_name)); | 28 GURL url(TestServerPage(page_name)); |
| 37 scoped_ptr<ResourceLoaderBridge> loader( | 29 scoped_ptr<ResourceLoaderBridge> loader( |
| 38 ResourceLoaderBridge::Create(NULL, "GET", | 30 ResourceLoaderBridge::Create(NULL, "GET", |
| 39 url, | 31 url, |
| 40 url, // policy_url | 32 url, // policy_url |
| 41 GURL(), // no referrer | 33 GURL(), // no referrer |
| 42 std::string(), // no extra headers | 34 std::string(), // no extra headers |
| 43 net::LOAD_NORMAL, | 35 net::LOAD_NORMAL, |
| 44 0, | 36 0, |
| 45 ResourceType::SUB_RESOURCE, | 37 ResourceType::SUB_RESOURCE, |
| 46 false)); | 38 false)); |
| 47 EXPECT_TRUE(loader.get()); | 39 EXPECT_TRUE(loader.get()); |
| 48 | 40 |
| 49 ResourceLoaderBridge::SyncLoadResponse resp; | 41 ResourceLoaderBridge::SyncLoadResponse resp; |
| 50 loader->SyncLoad(&resp); | 42 loader->SyncLoad(&resp); |
| 51 return resp.status.is_success(); | 43 return resp.status.is_success(); |
| 52 } | 44 } |
| 53 }; | 45 }; |
| 54 | 46 |
| 55 #endif // WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ | 47 #endif // WEBKIT_GLUE_UNITTEST_TEST_SERVER_H__ |
| 56 | 48 |
| OLD | NEW |