Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <atlbase.h> | |
| 9 #include <commdlg.h> | 8 #include <commdlg.h> |
| 10 #include <objbase.h> | 9 #include <objbase.h> |
| 10 #include <process.h> | |
| 11 #include <shlwapi.h> | 11 #include <shlwapi.h> |
| 12 #include <wininet.h> // For INTERNET_MAX_URL_LENGTH | 12 #include <wininet.h> // For INTERNET_MAX_URL_LENGTH |
| 13 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/memory_debug.h" | 16 #include "base/memory_debug.h" |
| 17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/resource_util.h" | 19 #include "base/resource_util.h" |
| 20 #include "base/stack_container.h" | 20 #include "base/stack_container.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 37 #include "webkit/tools/test_shell/test_shell_switches.h" | 37 #include "webkit/tools/test_shell/test_shell_switches.h" |
| 38 | 38 |
| 39 using WebKit::WebWidget; | 39 using WebKit::WebWidget; |
| 40 | 40 |
| 41 #define MAX_LOADSTRING 100 | 41 #define MAX_LOADSTRING 100 |
| 42 | 42 |
| 43 #define BUTTON_WIDTH 72 | 43 #define BUTTON_WIDTH 72 |
| 44 #define URLBAR_HEIGHT 24 | 44 #define URLBAR_HEIGHT 24 |
| 45 | 45 |
| 46 // Global Variables: | 46 // Global Variables: |
| 47 static TCHAR g_windowTitle[MAX_LOADSTRING]; // The title bar text | 47 static wchar_t g_windowTitle[MAX_LOADSTRING]; // The title bar text |
| 48 static TCHAR g_windowClass[MAX_LOADSTRING]; // The main window class name | 48 static wchar_t g_windowClass[MAX_LOADSTRING]; // The main window class name |
| 49 | 49 |
| 50 // This is only set for layout tests. It is used to determine the name of a | 50 // This is only set for layout tests. It is used to determine the name of a |
| 51 // minidump file. | 51 // minidump file. |
| 52 static const size_t kPathBufSize = 2048; | 52 static const size_t kPathBufSize = 2048; |
| 53 static wchar_t g_currentTestName[kPathBufSize]; | 53 static wchar_t g_currentTestName[kPathBufSize]; |
| 54 | 54 |
| 55 // Forward declarations of functions included in this code module: | 55 // Forward declarations of functions included in this code module: |
| 56 static INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); | 56 static INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); |
| 57 | 57 |
| 58 // Hide the window offscreen when in layout test mode. | 58 // Hide the window offscreen when in layout test mode. |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 if (bIsSVGTest) { | 512 if (bIsSVGTest) { |
| 513 SizeToSVG(); | 513 SizeToSVG(); |
| 514 } else { | 514 } else { |
| 515 // only resize back to the default when running tests | 515 // only resize back to the default when running tests |
| 516 if (layout_test_mode()) | 516 if (layout_test_mode()) |
| 517 SizeToDefault(); | 517 SizeToDefault(); |
| 518 } | 518 } |
| 519 | 519 |
| 520 std::wstring urlString(url); | 520 std::wstring urlString(url); |
| 521 if (!urlString.empty() && (PathFileExists(url) || PathIsUNC(url))) { | 521 if (!urlString.empty() && (PathFileExists(url) || PathIsUNC(url))) { |
| 522 TCHAR fileURL[INTERNET_MAX_URL_LENGTH]; | 522 wchar_t fileURL[INTERNET_MAX_URL_LENGTH]; |
| 523 DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]); | 523 DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]); |
|
Peter Kasting
2009/08/03 18:41:37
Nit: I'd just change this to INTERNET_MAX_URL_LENG
| |
| 524 if (SUCCEEDED(UrlCreateFromPath(url, fileURL, &fileURLLength, 0))) | 524 if (SUCCEEDED(UrlCreateFromPath(url, fileURL, &fileURLLength, 0))) |
| 525 urlString.assign(fileURL); | 525 urlString.assign(fileURL); |
| 526 } | 526 } |
| 527 | 527 |
| 528 std::wstring frame_string; | 528 std::wstring frame_string; |
| 529 if (frame_name) | 529 if (frame_name) |
| 530 frame_string = frame_name; | 530 frame_string = frame_name; |
| 531 | 531 |
| 532 navigation_controller_->LoadEntry(new TestNavigationEntry( | 532 navigation_controller_->LoadEntry(new TestNavigationEntry( |
| 533 -1, GURL(urlString), std::wstring(), frame_string)); | 533 -1, GURL(urlString), std::wstring(), frame_string)); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 return GetRawDataResource(::GetModuleHandle(NULL), key); | 679 return GetRawDataResource(::GetModuleHandle(NULL), key); |
| 680 } | 680 } |
| 681 | 681 |
| 682 | 682 |
| 683 ///////////////////////////////////////////////////////////////////////////// | 683 ///////////////////////////////////////////////////////////////////////////// |
| 684 // WebKit glue functions | 684 // WebKit glue functions |
| 685 | 685 |
| 686 namespace webkit_glue { | 686 namespace webkit_glue { |
| 687 | 687 |
| 688 string16 GetLocalizedString(int message_id) { | 688 string16 GetLocalizedString(int message_id) { |
| 689 const ATLSTRINGRESOURCEIMAGE* image = | 689 wchar_t localized[MAX_LOADSTRING]; |
| 690 AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(), | 690 int length = LoadString(GetModuleHandle(NULL), message_id, |
| 691 message_id); | 691 localized, MAX_LOADSTRING); |
| 692 if (!image) { | 692 if (!length && GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND) { |
| 693 NOTREACHED(); | 693 NOTREACHED(); |
| 694 return L"No string for this identifier!"; | 694 return L"No string for this identifier!"; |
| 695 } | 695 } |
| 696 return string16(image->achString, image->nLength); | 696 return string16(localized, length); |
| 697 } | 697 } |
| 698 | 698 |
| 699 // TODO(tc): Convert this to using resources from test_shell.rc. | 699 // TODO(tc): Convert this to using resources from test_shell.rc. |
| 700 StringPiece GetDataResource(int resource_id) { | 700 StringPiece GetDataResource(int resource_id) { |
| 701 switch (resource_id) { | 701 switch (resource_id) { |
| 702 case IDR_BROKENIMAGE: { | 702 case IDR_BROKENIMAGE: { |
| 703 // Use webkit's broken image icon (16x16) | 703 // Use webkit's broken image icon (16x16) |
| 704 static std::string broken_image_data; | 704 static std::string broken_image_data; |
| 705 if (broken_image_data.empty()) { | 705 if (broken_image_data.empty()) { |
| 706 FilePath path = GetResourcesFilePath(); | 706 FilePath path = GetResourcesFilePath(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 | 762 |
| 763 bool EnsureFontLoaded(HFONT font) { | 763 bool EnsureFontLoaded(HFONT font) { |
| 764 return true; | 764 return true; |
| 765 } | 765 } |
| 766 | 766 |
| 767 bool DownloadUrl(const std::string& url, HWND caller_window) { | 767 bool DownloadUrl(const std::string& url, HWND caller_window) { |
| 768 return false; | 768 return false; |
| 769 } | 769 } |
| 770 | 770 |
| 771 } // namespace webkit_glue | 771 } // namespace webkit_glue |
| OLD | NEW |