diff options
-rw-r--r-- | base/gfx/native_widget_types.h | 8 | ||||
-rw-r--r-- | build/SConscript.main | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/SConscript | 31 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_navigation_controller.cc | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_gtk.cc | 83 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main_gtk.cc | 65 | ||||
-rw-r--r-- | webkit/tools/test_shell/webwidget_host_gtk.cc | 15 |
7 files changed, 196 insertions, 16 deletions
diff --git a/base/gfx/native_widget_types.h b/base/gfx/native_widget_types.h index f9623db..b711b27 100644 --- a/base/gfx/native_widget_types.h +++ b/base/gfx/native_widget_types.h @@ -19,7 +19,9 @@ class NSView; class NSWindow; class NSTextField; #endif // __OBJC__ -#endif // MACOSX +#elif defined(OS_LINUX) +typedef struct _GtkWidget GtkWidget; +#endif namespace gfx { @@ -31,6 +33,10 @@ typedef HWND EditViewHandle; typedef NSView *ViewHandle; typedef NSWindow *WindowHandle; typedef NSTextField *EditViewHandle; +#elif defined(OS_LINUX) +typedef GtkWidget* ViewHandle; +typedef GtkWidget* WindowHandle; +typedef GtkWidget* EditViewHandle; #else // null port. typedef void* ViewHandle; typedef void* WindowHandle; diff --git a/build/SConscript.main b/build/SConscript.main index 2c62a7c..275df6d3 100644 --- a/build/SConscript.main +++ b/build/SConscript.main @@ -347,9 +347,9 @@ elif env['PLATFORM'] == 'posix': env.Append(CCFLAGS=['-fprofile-arcs', '-ftest-coverage']) env.Append(LINKFLAGS=['-fprofile-arcs']) - # Build with system-provided NSS and GLib + # Build with system-provided NSS and GTK. env.ParseConfig('pkg-config --cflags --libs nss') - env.ParseConfig('pkg-config --cflags --libs glib-2.0') + env.ParseConfig('pkg-config --cflags --libs gtk+-2.0') elif env['PLATFORM'] == 'darwin': diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript index 7491670..86a5e07 100644 --- a/webkit/tools/test_shell/SConscript +++ b/webkit/tools/test_shell/SConscript @@ -92,31 +92,37 @@ elif env['PLATFORM'] in ('posix', 'darwin'): ] ) -input_files = [] - +input_files = [ + 'test_navigation_controller.cc', + 'test_shell_switches.cc', +] if env['PLATFORM'] == 'win32': # TODO(port): put portable files in above test_files declaration. - input_files = [ + input_files.extend([ 'drag_delegate.cc', 'drop_delegate.cc', 'event_sending_controller.cc', 'layout_test_controller.cc', 'simple_resource_loader_bridge.cc', - 'test_navigation_controller.cc', 'test_shell.cc', - 'test_shell_switches.cc', 'test_shell_request_context.cc', 'test_webview_delegate.cc', 'text_input_controller.cc', 'webview_host.cc', 'webwidget_host.cc', - ] + ]) +elif env['PLATFORM'] == 'posix': + input_files.extend([ + 'test_shell_gtk.cc', + 'webwidget_host_gtk.cc', + ]) lib = env.ChromeStaticLibrary('test_shell', input_files) resources = [] +exe_input_files = [] if env['PLATFORM'] == 'win32': # TODO(port): figure out what to do with resources. resources = [ @@ -125,18 +131,21 @@ if env['PLATFORM'] == 'win32': '$WEBKIT_DIR/build/localized_strings/webkit_strings_en-US.res', ] - -if env['PLATFORM'] == 'win32': exe_input_files = [ 'test_shell_main.cc', '$V8_DIR/snapshot-empty$OBJSUFFIX' ] +elif env['PLATFORM'] == 'posix': + exe_input_files = [ + 'test_shell_main_gtk.cc', + ] - test_shell = env.ChromeProgram('test_shell', resources + exe_input_files) +test_shell = env.ChromeProgram('test_shell', resources + exe_input_files) - i = env.Install('$TARGET_ROOT', test_shell) - env.Alias('webkit', i) +i = env.Install('$TARGET_ROOT', test_shell) +env.Alias('webkit', i) +if env['PLATFORM'] == 'win32': env.Depends(test_shell, '$V8_DIR/vc80.pdb') test_files = [ diff --git a/webkit/tools/test_shell/test_navigation_controller.cc b/webkit/tools/test_shell/test_navigation_controller.cc index 8ee20b5..0c56115 100644 --- a/webkit/tools/test_shell/test_navigation_controller.cc +++ b/webkit/tools/test_shell/test_navigation_controller.cc @@ -34,13 +34,16 @@ void TestNavigationEntry::SetContentState(const std::string& state) { } WebHistoryItem* TestNavigationEntry::GetHistoryItem() const { + // TODO(port): temporary hack to get a basic test shell executable going. +#if !defined(OS_LINUX) if (!cached_history_item_) { - TestShellExtraRequestData* extra_data = + TestShellExtraRequestData* extra_data = new TestShellExtraRequestData(GetPageID()); cached_history_item_ = WebHistoryItem::Create(GetURL(), GetTitle(), GetContentState(), extra_data); } +#endif return cached_history_item_; } @@ -244,4 +247,3 @@ void TestNavigationController::UpdateMaxPageID() { if (entry) max_page_id_ = std::max(max_page_id_, entry->GetPageID()); } - diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc new file mode 100644 index 0000000..c441635 --- /dev/null +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -0,0 +1,83 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/tools/test_shell/test_shell.h" + +#include <gtk/gtk.h> + +#include "base/string_util.h" +#include "webkit/tools/test_shell/test_navigation_controller.h" + +WindowList* TestShell::window_list_; + +TestShell::TestShell() { +} + +TestShell::~TestShell() { +} + +// static +void TestShell::InitializeTestShell(bool interactive) { + window_list_ = new WindowList; +} + +// static +bool TestShell::CreateNewWindow(const std::wstring& startingURL, + TestShell** result) { + TestShell *shell = new TestShell(); + if (!shell->Initialize(startingURL)) + return false; + if (result) + *result = shell; + TestShell::windowList()->push_back(shell->m_mainWnd); + return true; +} + +bool TestShell::Initialize(const std::wstring& startingURL) { + m_mainWnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(m_mainWnd), "Test Shell"); + gtk_window_set_default_size(GTK_WINDOW(m_mainWnd), 640, 480); + + GtkWidget* vbox = gtk_vbox_new(FALSE, 0); + + GtkWidget* toolbar = gtk_toolbar_new(); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), + gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK), + -1 /* append */); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), + gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD), + -1 /* append */); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), + gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH), + -1 /* append */); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), + gtk_tool_button_new_from_stock(GTK_STOCK_STOP), + -1 /* append */); + + m_editWnd = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(m_editWnd), WideToUTF8(startingURL).c_str()); + + GtkToolItem* tool_item = gtk_tool_item_new(); + gtk_container_add(GTK_CONTAINER(tool_item), m_editWnd); + gtk_tool_item_set_expand(tool_item, TRUE); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), + tool_item, + -1 /* append */); + + gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); + + gtk_container_add(GTK_CONTAINER(m_mainWnd), vbox); + gtk_widget_show_all(m_mainWnd); + + return true; +} + +void TestShell::BindJSObjectsToWindow(WebFrame* frame) { + NOTIMPLEMENTED(); +} + +bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { + NOTIMPLEMENTED(); + return true; +} diff --git a/webkit/tools/test_shell/test_shell_main_gtk.cc b/webkit/tools/test_shell/test_shell_main_gtk.cc new file mode 100644 index 0000000..afee3e4 --- /dev/null +++ b/webkit/tools/test_shell/test_shell_main_gtk.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <gtk/gtk.h> + +#include "base/at_exit.h" +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/icu_util.h" +#include "base/path_service.h" +#include "base/string_util.h" +#include "webkit/tools/test_shell/test_shell.h" +#include "webkit/tools/test_shell/test_shell_switches.h" + +// TODO(port): This file is intended to match test_shell_main.cc. +// Remerge this back into test_shell_main once we have enough supporting pieces +// in place. + +int main(int argc, char* argv[]) { + // Make Singletons work. + base::AtExitManager at_exit_manager; + + gtk_init(&argc, &argv); + // Only parse the command line after GTK's had a crack at it. + CommandLine::SetArgcArgv(argc, argv); + + CommandLine parsed_command_line; + + icu_util::Initialize(); + + bool layout_test_mode = + parsed_command_line.HasSwitch(test_shell::kLayoutTests); + + bool interactive = !layout_test_mode; + TestShell::InitializeTestShell(interactive); + + // Treat the first loose value as the initial URL to open. + std::wstring uri; + + // Default to a homepage if we're interactive. + if (interactive) { + PathService::Get(base::DIR_SOURCE_ROOT, &uri); + file_util::AppendToPath(&uri, L"webkit"); + file_util::AppendToPath(&uri, L"data"); + file_util::AppendToPath(&uri, L"test_shell"); + file_util::AppendToPath(&uri, L"index.html"); + } + + if (parsed_command_line.GetLooseValueCount() > 0) { + CommandLine::LooseValueIterator iter = + parsed_command_line.GetLooseValuesBegin(); + uri = *iter; + } + + TestShell* shell; + if (TestShell::CreateNewWindow(uri, &shell)) { + // TODO(port): the rest of this. :) + } + + // TODO(port): use MessageLoop instead. + gtk_main(); + + return 0; +} diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc new file mode 100644 index 0000000..3b21839 --- /dev/null +++ b/webkit/tools/test_shell/webwidget_host_gtk.cc @@ -0,0 +1,15 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/tools/test_shell/webwidget_host.h" + +#include "base/logging.h" + +WebWidgetHost::WebWidgetHost() { + NOTIMPLEMENTED(); +} + +WebWidgetHost::~WebWidgetHost() { + NOTIMPLEMENTED(); +} |