diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-31 23:42:44 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-31 23:42:44 +0000 |
commit | aa156ca673791d7dfeffd02862c28a7b25f08c7c (patch) | |
tree | 115bf7392b8e3c986d4e2a9eb351453192971d2e /webkit | |
parent | f890108d79ed124f122b1e2526866e0e96410ff9 (diff) | |
download | chromium_src-aa156ca673791d7dfeffd02862c28a7b25f08c7c.zip chromium_src-aa156ca673791d7dfeffd02862c28a7b25f08c7c.tar.gz chromium_src-aa156ca673791d7dfeffd02862c28a7b25f08c7c.tar.bz2 |
Merge linux and windows test shells to share code.
This also forces the webkit grd files to be run through grit and .h files generated.
Review URL: http://codereview.chromium.org/8976
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4345 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/SConscript | 2 | ||||
-rw-r--r-- | webkit/build/localized_strings/SConscript | 28 | ||||
-rw-r--r-- | webkit/tools/test_shell/SConscript | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/gtk/test_shell.cc | 217 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 25 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_win.cc | 9 |
6 files changed, 53 insertions, 232 deletions
diff --git a/webkit/SConscript b/webkit/SConscript index d0fd611..1065e08 100644 --- a/webkit/SConscript +++ b/webkit/SConscript @@ -210,6 +210,7 @@ sconscript_dirs = [ 'SConscript.javascriptcore_pcre', 'build/JSConfig/SConscript', 'build/JavaScriptCore/SConscript', + 'build/localized_strings/SConscript', 'build/port/SConscript', 'build/V8Bindings/SConscript', 'build/WebCore/SConscript', @@ -225,7 +226,6 @@ if env['PLATFORM'] == 'win32': sconscript_dirs.extend([ 'activex_shim/SConscript', 'activex_shim_dll/SConscript', - 'build/localized_strings/SConscript', ]) env.Append( diff --git a/webkit/build/localized_strings/SConscript b/webkit/build/localized_strings/SConscript index d48719f..d964e49 100644 --- a/webkit/build/localized_strings/SConscript +++ b/webkit/build/localized_strings/SConscript @@ -8,17 +8,21 @@ env = env.Clone() env_res = env_res.Clone() env_res.Append( - CPPPATH = [ - ".", - #"$CHROME_SRC_DIR/chrome/Debug/obj/chrome_dll", - "$CHROME_SRC_DIR", - #"$CHROME_SRC_DIR/chrome/Debug/obj", - ], - RCFLAGS = [ - ["/l", "0x409"], - ], + CPPPATH = [ + ".", + #"$CHROME_SRC_DIR/chrome/Debug/obj/chrome_dll", + "$CHROME_SRC_DIR", + #"$CHROME_SRC_DIR/chrome/Debug/obj", + ], ) +if env_res['PLATFORM'] == 'win32': + env_res.Append( + RCFLAGS = [ + ["/l", "0x409"], + ], + ) + import os import sys sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath) @@ -28,7 +32,7 @@ env_grd.Tool('scons', toolpath=[env_grd.Dir('$CHROME_SRC_DIR/tools/grit/grit')]) # to put the target files. generated = env_grd.GRIT('webkit_strings', '$CHROME_SRC_DIR/webkit/glue/webkit_strings.grd') -for g in [ g for g in generated if str(g).endswith('.rc') ]: - env_res.RES(g) - +if env_res['PLATFORM'] == 'win32': + for g in [g for g in generated if str(g).endswith('.rc')]: + env_res.RES(g) diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript index 30c4f96..94f4b54 100644 --- a/webkit/tools/test_shell/SConscript +++ b/webkit/tools/test_shell/SConscript @@ -99,16 +99,16 @@ input_files = [ 'test_navigation_controller.cc', 'test_shell_request_context.cc', 'test_shell_switches.cc', + 'test_shell.cc', + 'text_input_controller.cc', ] if env['PLATFORM'] == 'win32': # TODO(port): put portable files in above test_files declaration. input_files.extend([ 'drag_delegate.cc', 'drop_delegate.cc', - 'test_shell.cc', 'test_shell_win.cc', 'test_webview_delegate.cc', - 'text_input_controller.cc', 'webview_host.cc', 'webwidget_host.cc', ]) diff --git a/webkit/tools/test_shell/gtk/test_shell.cc b/webkit/tools/test_shell/gtk/test_shell.cc index 2f701a4..cc3792c 100644 --- a/webkit/tools/test_shell/gtk/test_shell.cc +++ b/webkit/tools/test_shell/gtk/test_shell.cc @@ -25,22 +25,6 @@ #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_webview_delegate.h" -WebPreferences* TestShell::web_prefs_ = NULL; - -WindowList* TestShell::window_list_; - -TestShell::TestShell() - : delegate_(new TestWebViewDelegate(this)) { - layout_test_controller_.reset(new LayoutTestController(this)); - event_sending_controller_.reset(new EventSendingController(this)); - navigation_controller_.reset(new TestNavigationController(this)); -} - -TestShell::~TestShell() { -} - -bool TestShell::interactive_ = false; - // static void TestShell::InitializeTestShell(bool interactive) { window_list_ = new WindowList; @@ -60,42 +44,7 @@ bool TestShell::CreateNewWindow(const std::wstring& startingURL, return true; } -void TestShell::ResetWebPreferences() { - DCHECK(web_prefs_); - - // Match the settings used by Mac DumpRenderTree. - if (web_prefs_) { - *web_prefs_ = WebPreferences(); - web_prefs_->standard_font_family = L"Times"; - web_prefs_->fixed_font_family = L"Courier"; - web_prefs_->serif_font_family = L"Times"; - web_prefs_->sans_serif_font_family = L"Helvetica"; - // These two fonts are picked from the intersection of - // Win XP font list and Vista font list : - // http://www.microsoft.com/typography/fonts/winxp.htm - // http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx - // Some of them are installed only with CJK and complex script - // support enabled on Windows XP and are out of consideration here. - // (although we enabled both on our buildbots.) - // They (especially Impact for fantasy) are not typical cursive - // and fantasy fonts, but it should not matter for layout tests - // as long as they're available. - web_prefs_->cursive_font_family = L"Comic Sans MS"; - web_prefs_->fantasy_font_family = L"Impact"; - web_prefs_->default_encoding = L"ISO-8859-1"; - web_prefs_->default_font_size = 16; - web_prefs_->default_fixed_font_size = 13; - web_prefs_->minimum_font_size = 1; - web_prefs_->minimum_logical_font_size = 9; - web_prefs_->javascript_can_open_windows_automatically = true; - web_prefs_->dom_paste_enabled = true; - web_prefs_->developer_extras_enabled = interactive_; - web_prefs_->shrinks_standalone_images_to_fit = false; - web_prefs_->uses_universal_detector = false; - web_prefs_->text_areas_are_resizable = false; - web_prefs_->java_enabled = true; - web_prefs_->allow_scripts_to_close_windows = false; - } +void TestShell::PlatformCleanUp() { } bool TestShell::Initialize(const std::wstring& startingURL) { @@ -145,23 +94,23 @@ void TestShell::TestFinished() { NOTIMPLEMENTED(); } -void TestShell::WaitTestFinished() { - DCHECK(!test_is_pending_) << "cannot be used recursively"; +void TestShell::SizeTo(int width, int height) { + NOTIMPLEMENTED(); +} - test_is_pending_ = true; +void TestShell::WaitTestFinished() { + DCHECK(!test_is_pending_) << "cannot be used recursively"; - // TODO(agl): Here windows forks a watchdog thread, but I'm punting on that - // for the moment. On POSIX systems we probably want to install a signal - // handler and use alarm(2). + test_is_pending_ = true; - // TestFinished() will post a quit message to break this loop when the page - // finishes loading. - while (test_is_pending_) - MessageLoop::current()->Run(); -} + // TODO(agl): Here windows forks a watchdog thread, but I'm punting on that + // for the moment. On POSIX systems we probably want to install a signal + // handler and use alarm(2). -void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) { - delegate_->Show(webview, disposition); + // TestFinished() will post a quit message to break this loop when the page + // finishes loading. + while (test_is_pending_) + MessageLoop::current()->Run(); } void TestShell::SetFocus(WebWidgetHost* host, bool enable) { @@ -169,19 +118,10 @@ void TestShell::SetFocus(WebWidgetHost* host, bool enable) { NOTIMPLEMENTED(); } -void TestShell::BindJSObjectsToWindow(WebFrame* frame) { - NOTIMPLEMENTED(); -} - void TestShell::DestroyWindow(gfx::WindowHandle windowHandle) { NOTIMPLEMENTED(); } -WebView* TestShell::CreateWebView(WebView* webview) { - NOTIMPLEMENTED(); - return NULL; -} - WebWidget* TestShell::CreatePopupWidget(WebView* webview) { NOTIMPLEMENTED(); return NULL; @@ -320,11 +260,6 @@ void TestShell::ResizeSubViews() { return true; } -void TestShell::LoadURL(const wchar_t* url) -{ - LoadURLForFrame(url, NULL); -} - void TestShell::LoadURLForFrame(const wchar_t* url, const wchar_t* frame_name) { if (!url) @@ -341,49 +276,6 @@ void TestShell::LoadURLForFrame(const wchar_t* url, -1, GURL(WideToUTF8(url)), std::wstring(), frame_string)); } -bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { - WebRequestCachePolicy cache_policy; - if (reload) { - cache_policy = WebRequestReloadIgnoringCacheData; - } else if (entry.GetPageID() != -1) { - cache_policy = WebRequestReturnCacheDataElseLoad; - } else { - cache_policy = WebRequestUseProtocolCachePolicy; - } - - scoped_ptr<WebRequest> request(WebRequest::Create(entry.GetURL())); - request->SetCachePolicy(cache_policy); - // If we are reloading, then WebKit will use the state of the current page. - // Otherwise, we give it the state to navigate to. - if (!reload) - request->SetHistoryState(entry.GetContentState()); - - request->SetExtraData( - new TestShellExtraRequestData(entry.GetPageID())); - - // Get the right target frame for the entry. - WebFrame* frame = webView()->GetMainFrame(); - if (!entry.GetTargetFrame().empty()) - frame = webView()->GetFrameWithName(entry.GetTargetFrame()); - // TODO(mpcomplete): should we clear the target frame, or should - // back/forward navigations maintain the target frame? - - frame->LoadRequest(request.get()); - // Restore focus to the main frame prior to loading new request. - // This makes sure that we don't have a focused iframe. Otherwise, that - // iframe would keep focus when the SetFocus called immediately after - // LoadRequest, thus making some tests fail (see http://b/issue?id=845337 - // for more details). - webView()->SetFocusedFrame(frame); - SetFocus(webViewHost(), true); - - return true; -} - -void TestShell::GoBackOrForward(int offset) { - navigation_controller_->GoToOffset(offset); -} - static void WriteTextToFile(const std::wstring& data, const FilePath& filepath) { @@ -403,11 +295,6 @@ static void WriteTextToFile(const std::wstring& data, } -std::wstring TestShell::GetDocumentText() -{ - return webkit_glue::DumpDocumentText(webView()->GetMainFrame()); -} - // TODO(agl): // This version of PromptForSaveFile uses FilePath, which is what the real // version should be using. However, I don't want to step on tony's toes (as he @@ -443,10 +330,6 @@ void TestShell::DumpRenderTree() file_path); } -void TestShell::Reload() { - navigation_controller_->Reload(); -} - std::string TestShell::RewriteLocalUrl(const std::string& url) { // Convert file:///tmp/LayoutTests urls to the actual location on disk. const char kPrefix[] = "file:///tmp/LayoutTests/"; @@ -473,91 +356,19 @@ std::string TestShell::RewriteLocalUrl(const std::string& url) { namespace webkit_glue { -void PrefetchDns(const std::string& hostname) {} - -void PrecacheUrl(const char16* url, int url_length) {} - -void AppendToLog(const char* file, int line, const char* msg) { - logging::LogMessage(file, line).stream() << msg; -} - -bool GetMimeTypeFromExtension(const std::wstring &ext, std::string *mime_type) { - return net::GetMimeTypeFromExtension(ext, mime_type); -} - -bool GetMimeTypeFromFile(const std::wstring &file_path, - std::string *mime_type) { - return net::GetMimeTypeFromFile(file_path, mime_type); -} - -bool GetPreferredExtensionForMimeType(const std::string& mime_type, - std::wstring* ext) { - return net::GetPreferredExtensionForMimeType(mime_type, ext); -} - std::wstring GetLocalizedString(int message_id) { NOTREACHED(); return L"No string for this identifier!"; } -std::string GetDataResource(int resource_id) { - NOTREACHED(); - return std::string(); -} - -SkBitmap* GetBitmapResource(int resource_id) { - return NULL; -} - -bool GetApplicationDirectory(std::wstring *path) { - return PathService::Get(base::DIR_EXE, path); -} - -GURL GetInspectorURL() { - return GURL("test-shell-resource://inspector/inspector.html"); -} - -std::string GetUIResourceProtocol() { - return "test-shell-resource"; -} - -bool GetExeDirectory(std::wstring *path) { - return PathService::Get(base::DIR_EXE, path); -} - -bool SpellCheckWord(const wchar_t* word, int word_len, - int* misspelling_start, int* misspelling_len) { - // Report all words being correctly spelled. - *misspelling_start = 0; - *misspelling_len = 0; - return true; -} - bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { - //return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); NOTIMPLEMENTED(); return false; } -bool IsPluginRunningInRendererProcess() { - return true; -} - ScreenInfo GetScreenInfo(gfx::ViewHandle window) { NOTIMPLEMENTED(); return ScreenInfo(); } -bool GetPluginFinderURL(std::string* plugin_finder_url) { - return false; -} - -bool IsDefaultPluginEnabled() { - return false; -} - -std::wstring GetWebKitLocale() { - return L"en-US"; -} - } // namespace webkit_glue diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 1fa4107..5199a87 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/debug_on_start.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/gfx/bitmap_platform_device.h" #include "base/gfx/size.h" @@ -14,6 +15,7 @@ #include "base/path_service.h" #include "base/stats_table.h" #include "base/string_util.h" +#include "build/build_config.h" #include "googleurl/src/url_util.h" #include "net/base/mime_util.h" #include "net/url_request/url_request_file_job.h" @@ -27,7 +29,6 @@ #include "webkit/glue/weburlrequest.h" #include "webkit/glue/webview.h" #include "webkit/glue/webwidget.h" -#include "webkit/glue/plugins/plugin_list.h" #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit_strings.h" @@ -78,7 +79,9 @@ TestShell::TestShell() m_webViewHost(NULL), m_popupHost(NULL), m_focusedWidgetHost(NULL), +#if defined(OS_WIN) default_edit_wnd_proc_(0), +#endif test_is_preparing_(false), test_is_pending_(false), is_modal_(false), @@ -97,7 +100,6 @@ TestShell::TestShell() TestShell::~TestShell() { - // Call GC twice to clean up garbage. CallJSGC(); CallJSGC(); @@ -122,14 +124,17 @@ TestShell::~TestShell() { } } +#if defined(OS_WIN) // All fatal log messages (e.g. DCHECK failures) imply unit test failures static void UnitTestAssertHandler(const std::string& str) { FAIL() << str; } +#endif // static void TestShell::InitLogging(bool suppress_error_dialogs, bool running_layout_tests) { +#if defined(OS_WIN) if (!IsDebuggerPresent() && suppress_error_dialogs) { UINT new_flags = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | @@ -140,6 +145,7 @@ void TestShell::InitLogging(bool suppress_error_dialogs, logging::SetLogAssertHandler(UnitTestAssertHandler); } +#endif // Only log to a file if we're running layout tests. This prevents debugging // output from disrupting whether or not we pass. @@ -149,10 +155,10 @@ void TestShell::InitLogging(bool suppress_error_dialogs, destination = logging::LOG_ONLY_TO_FILE; // We might have multiple test_shell processes going at once - std::wstring log_filename; + FilePath log_filename; PathService::Get(base::DIR_EXE, &log_filename); - file_util::AppendToPath(&log_filename, L"test_shell.log"); - logging::InitLogging(log_filename.c_str(), + log_filename.Append(FILE_PATH_LITERAL("test_shell.log")); + logging::InitLogging(log_filename.value().c_str(), destination, logging::LOCK_LOG_FILE, logging::DELETE_OLD_LOG_FILE); @@ -251,7 +257,6 @@ void TestShell::SizeToDefault() { SizeTo(kTestWindowWidth, kTestWindowHeight); } - void TestShell::LoadURL(const wchar_t* url) { LoadURLForFrame(url, NULL); } @@ -390,18 +395,10 @@ bool SpellCheckWord(const wchar_t* word, int word_len, return true; } -bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { - return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); -} - bool IsPluginRunningInRendererProcess() { return true; } -ScreenInfo GetScreenInfo(gfx::ViewHandle window) { - return GetScreenInfoHelper(window); -} - bool GetPluginFinderURL(std::string* plugin_finder_url) { return false; } diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index 4c092b9..b8b6ef0 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -26,6 +26,7 @@ #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" +#include "webkit/glue/plugins/plugin_list.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "webkit/tools/test_shell/test_navigation_controller.h" @@ -725,6 +726,10 @@ HCURSOR LoadCursor(int cursor_id) { return NULL; } +bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { + return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); +} + bool EnsureFontLoaded(HFONT font) { return true; } @@ -733,4 +738,8 @@ bool DownloadUrl(const std::string& url, HWND caller_window) { return false; } +ScreenInfo GetScreenInfo(gfx::ViewHandle window) { + return GetScreenInfoHelper(window); +} + } // namespace webkit_glue |