| 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 #include "webkit/tools/test_shell/test_shell_test.h" | 5 #include "webkit/tools/test_shell/test_shell_test.h" | 
| 6 | 6 | 
|  | 7 #include <string> | 
|  | 8 | 
| 7 #include "base/basictypes.h" | 9 #include "base/basictypes.h" | 
|  | 10 #include "base/file_path.h" | 
| 8 #include "base/file_util.h" | 11 #include "base/file_util.h" | 
| 9 #include "base/message_loop.h" | 12 #include "base/message_loop.h" | 
| 10 #include "base/path_service.h" | 13 #include "base/path_service.h" | 
| 11 #include "base/string_util.h" | 14 #include "base/string_util.h" | 
| 12 | 15 | 
| 13 std::wstring TestShellTest::GetTestURL(std::wstring test_case_path, | 16 std::wstring TestShellTest::GetTestURL(const FilePath& test_case_path, | 
| 14                                        const std::wstring& test_case) { | 17                                        const std::string& test_case) { | 
| 15   file_util::AppendToPath(&test_case_path, test_case); | 18   return test_case_path.AppendASCII(test_case).ToWStringHack(); | 
| 16   return test_case_path; |  | 
| 17 } | 19 } | 
| 18 | 20 | 
| 19 void TestShellTest::SetUp() { | 21 void TestShellTest::SetUp() { | 
| 20   // Make a test shell for use by the test. | 22   // Make a test shell for use by the test. | 
| 21   CreateEmptyWindow(); | 23   CreateEmptyWindow(); | 
| 22   test_shell_->Show(test_shell_->webView(), NEW_WINDOW); | 24   test_shell_->Show(test_shell_->webView(), NEW_WINDOW); | 
| 23 | 25 | 
| 24   // Point data_dir_ to the root of the test case dir | 26   // Point data_dir_ to the root of the test case dir | 
| 25   ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir_)); | 27   ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir_)); | 
| 26   file_util::AppendToPath(&data_dir_, L"webkit"); | 28   data_dir_ = data_dir_.Append(FILE_PATH_LITERAL("webkit")); | 
| 27   file_util::AppendToPath(&data_dir_, L"data"); | 29   data_dir_ = data_dir_.Append(FILE_PATH_LITERAL("data")); | 
| 28   ASSERT_TRUE(file_util::PathExists(data_dir_)); | 30   ASSERT_TRUE(file_util::PathExists(data_dir_)); | 
| 29 } | 31 } | 
| 30 | 32 | 
| 31 void TestShellTest::TearDown() { | 33 void TestShellTest::TearDown() { | 
| 32   // Loading a blank url clears the memory in the current page. | 34   // Loading a blank url clears the memory in the current page. | 
| 33   test_shell_->LoadURL(L"about:blank"); | 35   test_shell_->LoadURL(L"about:blank"); | 
| 34   test_shell_->DestroyWindow(test_shell_->mainWnd()); | 36   test_shell_->DestroyWindow(test_shell_->mainWnd()); | 
| 35   LayoutTestController::ClearShell(); | 37   LayoutTestController::ClearShell(); | 
| 36 | 38 | 
| 37   // Flush the MessageLoop of any residual tasks. | 39   // Flush the MessageLoop of any residual tasks. | 
| 38   MessageLoop::current()->RunAllPending(); | 40   MessageLoop::current()->RunAllPending(); | 
| 39 } | 41 } | 
| 40 | 42 | 
| 41 void TestShellTest::CreateEmptyWindow() { | 43 void TestShellTest::CreateEmptyWindow() { | 
| 42   TestShell::CreateNewWindow(L"about:blank", &test_shell_); | 44   TestShell::CreateNewWindow(L"about:blank", &test_shell_); | 
| 43 } | 45 } | 
| OLD | NEW | 
|---|