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

Side by Side Diff: webkit/tools/test_shell/test_shell_win.cc

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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.h" 5 #include "webkit/tools/test_shell/test_shell.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <commdlg.h> 8 #include <commdlg.h>
9 #include <objbase.h> 9 #include <objbase.h>
10 #include <process.h> 10 #include <process.h>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Warning: Don't use the heap in this function. It may be corrupted. 94 // Warning: Don't use the heap in this function. It may be corrupted.
95 if (!g_currentTestName[0]) 95 if (!g_currentTestName[0])
96 return false; 96 return false;
97 97
98 // Try to rename the minidump file to include the crashed test's name. 98 // Try to rename the minidump file to include the crashed test's name.
99 // StackString uses the stack but overflows onto the heap. But we don't 99 // StackString uses the stack but overflows onto the heap. But we don't
100 // care too much about being completely correct here, since most crashes 100 // care too much about being completely correct here, since most crashes
101 // will be happening on developers' machines where they have debuggers. 101 // will be happening on developers' machines where they have debuggers.
102 base::StackString16<kPathBufSize * 2> origPath; 102 base::StackString16<kPathBufSize * 2> origPath;
103 origPath->append(dumpPath); 103 origPath->append(dumpPath);
104 origPath->push_back(FilePath::kSeparators[0]); 104 origPath->push_back(base::FilePath::kSeparators[0]);
105 origPath->append(minidumpID); 105 origPath->append(minidumpID);
106 origPath->append(L".dmp"); 106 origPath->append(L".dmp");
107 107
108 base::StackString16<kPathBufSize * 2> newPath; 108 base::StackString16<kPathBufSize * 2> newPath;
109 newPath->append(dumpPath); 109 newPath->append(dumpPath);
110 newPath->push_back(FilePath::kSeparators[0]); 110 newPath->push_back(base::FilePath::kSeparators[0]);
111 newPath->append(g_currentTestName); 111 newPath->append(g_currentTestName);
112 newPath->append(L"-"); 112 newPath->append(L"-");
113 newPath->append(minidumpID); 113 newPath->append(minidumpID);
114 newPath->append(L".dmp"); 114 newPath->append(L".dmp");
115 115
116 // May use the heap, but oh well. If this fails, we'll just have the 116 // May use the heap, but oh well. If this fails, we'll just have the
117 // original dump file lying around. 117 // original dump file lying around.
118 _wrename(origPath->c_str(), newPath->c_str()); 118 _wrename(origPath->c_str(), newPath->c_str());
119 119
120 return false; 120 return false;
121 } 121 }
122 122
123 // Helper method for getting the path to the test shell resources directory. 123 // Helper method for getting the path to the test shell resources directory.
124 FilePath GetResourcesFilePath() { 124 base::FilePath GetResourcesFilePath() {
125 FilePath path; 125 base::FilePath path;
126 PathService::Get(base::DIR_SOURCE_ROOT, &path); 126 PathService::Get(base::DIR_SOURCE_ROOT, &path);
127 path = path.AppendASCII("webkit"); 127 path = path.AppendASCII("webkit");
128 path = path.AppendASCII("tools"); 128 path = path.AppendASCII("tools");
129 path = path.AppendASCII("test_shell"); 129 path = path.AppendASCII("test_shell");
130 return path.AppendASCII("resources"); 130 return path.AppendASCII("resources");
131 } 131 }
132 132
133 static base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { 133 static base::StringPiece GetRawDataResource(HMODULE module, int resource_id) {
134 void* data_ptr; 134 void* data_ptr;
135 size_t data_size; 135 size_t data_size;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 } 245 }
246 246
247 std::string TestShell::RewriteLocalUrl(const std::string& url) { 247 std::string TestShell::RewriteLocalUrl(const std::string& url) {
248 // Convert file:///tmp/LayoutTests urls to the actual location on disk. 248 // Convert file:///tmp/LayoutTests urls to the actual location on disk.
249 const char kPrefix[] = "file:///tmp/LayoutTests/"; 249 const char kPrefix[] = "file:///tmp/LayoutTests/";
250 const int kPrefixLen = arraysize(kPrefix) - 1; 250 const int kPrefixLen = arraysize(kPrefix) - 1;
251 251
252 std::string new_url(url); 252 std::string new_url(url);
253 if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { 253 if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) {
254 FilePath replace_url; 254 base::FilePath replace_url;
255 PathService::Get(base::DIR_EXE, &replace_url); 255 PathService::Get(base::DIR_EXE, &replace_url);
256 replace_url = replace_url.DirName(); 256 replace_url = replace_url.DirName();
257 replace_url = replace_url.DirName(); 257 replace_url = replace_url.DirName();
258 replace_url = replace_url.AppendASCII("third_party"); 258 replace_url = replace_url.AppendASCII("third_party");
259 replace_url = replace_url.AppendASCII("WebKit"); 259 replace_url = replace_url.AppendASCII("WebKit");
260 replace_url = replace_url.AppendASCII("LayoutTests"); 260 replace_url = replace_url.AppendASCII("LayoutTests");
261 string16 replace_url_str = replace_url.value(); 261 string16 replace_url_str = replace_url.value();
262 replace_url_str.push_back(L'/'); 262 replace_url_str.push_back(L'/');
263 new_url = std::string("file:///") + 263 new_url = std::string("file:///") +
264 UTF16ToUTF8(replace_url_str).append(url.substr(kPrefixLen)); 264 UTF16ToUTF8(replace_url_str).append(url.substr(kPrefixLen));
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { 633 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
634 EndDialog(hDlg, LOWORD(wParam)); 634 EndDialog(hDlg, LOWORD(wParam));
635 return (INT_PTR)TRUE; 635 return (INT_PTR)TRUE;
636 } 636 }
637 break; 637 break;
638 } 638 }
639 return (INT_PTR)FALSE; 639 return (INT_PTR)FALSE;
640 } 640 }
641 641
642 bool TestShell::PromptForSaveFile(const wchar_t* prompt_title, 642 bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
643 FilePath* result) { 643 base::FilePath* result) {
644 wchar_t path_buf[MAX_PATH] = L"data.txt"; 644 wchar_t path_buf[MAX_PATH] = L"data.txt";
645 645
646 OPENFILENAME info = {0}; 646 OPENFILENAME info = {0};
647 info.lStructSize = sizeof(info); 647 info.lStructSize = sizeof(info);
648 info.hwndOwner = m_mainWnd; 648 info.hwndOwner = m_mainWnd;
649 info.hInstance = instance_handle_; 649 info.hInstance = instance_handle_;
650 info.lpstrFilter = L"*.txt\0"; 650 info.lpstrFilter = L"*.txt\0";
651 info.lpstrFile = path_buf; 651 info.lpstrFile = path_buf;
652 info.nMaxFile = arraysize(path_buf); 652 info.nMaxFile = arraysize(path_buf);
653 info.lpstrTitle = prompt_title; 653 info.lpstrTitle = prompt_title;
654 if (!GetSaveFileName(&info)) 654 if (!GetSaveFileName(&info))
655 return false; 655 return false;
656 656
657 *result = FilePath(info.lpstrFile); 657 *result = base::FilePath(info.lpstrFile);
658 return true; 658 return true;
659 } 659 }
660 660
661 // static 661 // static
662 void TestShell::ShowStartupDebuggingDialog() { 662 void TestShell::ShowStartupDebuggingDialog() {
663 MessageBox(NULL, L"attach to me?", L"test_shell", MB_OK); 663 MessageBox(NULL, L"attach to me?", L"test_shell", MB_OK);
664 } 664 }
665 665
666 // static 666 // static
667 base::StringPiece TestShell::ResourceProvider(int key) { 667 base::StringPiece TestShell::ResourceProvider(int key) {
(...skipping 14 matching lines...) Expand all
682 682
683 // TODO(tc): Convert this to using resources from test_shell.rc. 683 // TODO(tc): Convert this to using resources from test_shell.rc.
684 base::StringPiece TestShellWebKitInit::GetDataResource( 684 base::StringPiece TestShellWebKitInit::GetDataResource(
685 int resource_id, 685 int resource_id,
686 ui::ScaleFactor scale_factor) { 686 ui::ScaleFactor scale_factor) {
687 switch (resource_id) { 687 switch (resource_id) {
688 case IDR_BROKENIMAGE: { 688 case IDR_BROKENIMAGE: {
689 // Use webkit's broken image icon (16x16) 689 // Use webkit's broken image icon (16x16)
690 static std::string broken_image_data; 690 static std::string broken_image_data;
691 if (broken_image_data.empty()) { 691 if (broken_image_data.empty()) {
692 FilePath path = GetResourcesFilePath(); 692 base::FilePath path = GetResourcesFilePath();
693 path = path.AppendASCII("missingImage.gif"); 693 path = path.AppendASCII("missingImage.gif");
694 bool success = file_util::ReadFileToString(path, &broken_image_data); 694 bool success = file_util::ReadFileToString(path, &broken_image_data);
695 if (!success) { 695 if (!success) {
696 LOG(FATAL) << "Failed reading: " << path.value(); 696 LOG(FATAL) << "Failed reading: " << path.value();
697 } 697 }
698 } 698 }
699 return broken_image_data; 699 return broken_image_data;
700 } 700 }
701 case IDR_TEXTAREA_RESIZER: { 701 case IDR_TEXTAREA_RESIZER: {
702 // Use webkit's text area resizer image. 702 // Use webkit's text area resizer image.
703 static std::string resize_corner_data; 703 static std::string resize_corner_data;
704 if (resize_corner_data.empty()) { 704 if (resize_corner_data.empty()) {
705 FilePath path = GetResourcesFilePath(); 705 base::FilePath path = GetResourcesFilePath();
706 path = path.AppendASCII("textAreaResizeCorner.png"); 706 path = path.AppendASCII("textAreaResizeCorner.png");
707 bool success = file_util::ReadFileToString(path, &resize_corner_data); 707 bool success = file_util::ReadFileToString(path, &resize_corner_data);
708 if (!success) { 708 if (!success) {
709 LOG(FATAL) << "Failed reading: " << path.value(); 709 LOG(FATAL) << "Failed reading: " << path.value();
710 } 710 }
711 } 711 }
712 return resize_corner_data; 712 return resize_corner_data;
713 } 713 }
714 714
715 case IDR_SEARCH_CANCEL: 715 case IDR_SEARCH_CANCEL:
(...skipping 28 matching lines...) Expand all
744 744
745 bool EnsureFontLoaded(HFONT font) { 745 bool EnsureFontLoaded(HFONT font) {
746 return true; 746 return true;
747 } 747 }
748 748
749 bool DownloadUrl(const std::string& url, HWND caller_window) { 749 bool DownloadUrl(const std::string& url, HWND caller_window) {
750 return false; 750 return false;
751 } 751 }
752 752
753 } // namespace webkit_glue 753 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell_webkit_init.cc ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698