OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "webkit/tools/test_shell/test_shell_test.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/file_util.h" | |
11 #include "base/files/file_path.h" | |
12 #include "base/message_loop.h" | |
13 #include "base/path_service.h" | |
14 #include "base/string_util.h" | |
15 #include "googleurl/src/gurl.h" | |
16 #include "net/base/net_util.h" | |
17 #include "webkit/user_agent/user_agent.h" | |
18 #include "webkit/user_agent/user_agent_util.h" | |
19 | |
20 GURL TestShellTest::GetTestURL(const base::FilePath& test_case_path, | |
21 const std::string& test_case) { | |
22 return net::FilePathToFileURL(test_case_path.AppendASCII(test_case)); | |
23 } | |
24 | |
25 void TestShellTest::SetUp() { | |
26 // Make a test shell for use by the test. | |
27 CreateEmptyWindow(); | |
28 test_shell_->Show(WebKit::WebNavigationPolicyNewWindow); | |
29 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( | |
30 "TestShell/0.0.0.0"), false); | |
31 | |
32 // Point data_dir_ to the root of the test case dir | |
33 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir_)); | |
34 data_dir_ = data_dir_.Append(FILE_PATH_LITERAL("webkit")); | |
35 data_dir_ = data_dir_.Append(FILE_PATH_LITERAL("data")); | |
36 ASSERT_TRUE(file_util::PathExists(data_dir_)); | |
37 } | |
38 | |
39 void TestShellTest::TearDown() { | |
40 // Loading a blank url clears the memory in the current page. | |
41 test_shell_->LoadURL(GURL("about:blank")); | |
42 test_shell_->DestroyWindow(test_shell_->mainWnd()); | |
43 | |
44 // Flush the MessageLoop of any residual tasks. | |
45 MessageLoop::current()->RunUntilIdle(); | |
46 } | |
47 | |
48 void TestShellTest::CreateEmptyWindow() { | |
49 TestShell::CreateNewWindow(GURL("about:blank"), &test_shell_); | |
50 } | |
OLD | NEW |