summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 14:33:54 +0000
committerpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 14:33:54 +0000
commit170ab4a8f224abffa7fbeef190fada5316ed5be9 (patch)
treef7fabbce26129895ebf308107e6b1d668b9c449c
parent54ced96f736e3634beb134b4a1cadc22da44b9f4 (diff)
downloadchromium_src-170ab4a8f224abffa7fbeef190fada5316ed5be9.zip
chromium_src-170ab4a8f224abffa7fbeef190fada5316ed5be9.tar.gz
chromium_src-170ab4a8f224abffa7fbeef190fada5316ed5be9.tar.bz2
Remove shared code from test_shell_mac, build test_shell_cc. Add a missing file to the net project. Fix leaks on exit where TestShell object was never getting cleaned up.
Review URL: http://codereview.chromium.org/10602 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5256 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/net.xcodeproj/project.pbxproj8
-rw-r--r--webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj4
-rw-r--r--webkit/tools/test_shell/mac/main.mm65
-rw-r--r--webkit/tools/test_shell/test_shell.cc11
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm383
5 files changed, 91 insertions, 380 deletions
diff --git a/net/net.xcodeproj/project.pbxproj b/net/net.xcodeproj/project.pbxproj
index c28ba90..7f007aa 100644
--- a/net/net.xcodeproj/project.pbxproj
+++ b/net/net.xcodeproj/project.pbxproj
@@ -161,6 +161,7 @@
BAA46E3B0E5CE99A00E77460 /* net_util_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED329F0E5A181C00A747DB /* net_util_unittest.cc */; };
DFEE18270E882E3600666107 /* stats_histogram.cc in Sources */ = {isa = PBXBuildFile; fileRef = DFEE18250E882E3600666107 /* stats_histogram.cc */; };
E4005E3A0E9FA63B0055B38E /* url_request_file_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED33B00E5A198600A747DB /* url_request_file_job.cc */; };
+ E45449720ECA0264000DFA6E /* url_request_filter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED33B90E5A198600A747DB /* url_request_filter.cc */; };
E47E933F0E8924DC00CA613E /* tcp_client_socket_libevent.cc in Sources */ = {isa = PBXBuildFile; fileRef = E47E933E0E8924DC00CA613E /* tcp_client_socket_libevent.cc */; };
E47E93430E8924EE00CA613E /* tcp_client_socket_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED328E0E5A181C00A747DB /* tcp_client_socket_unittest.cc */; };
E49DD2EA0E892F8C003C7A87 /* sdch_manager.cc in Sources */ = {isa = PBXBuildFile; fileRef = E49DD2E80E892F8C003C7A87 /* sdch_manager.cc */; };
@@ -1479,6 +1480,7 @@
7B8504280E5B2E2A00730B43 /* hash.cc in Sources */,
7B82FF430E763602008F45CF /* host_resolver.cc in Sources */,
0435A4660E8DD69C00E4DF08 /* http_auth.cc in Sources */,
+ 04E7BD550EC4ECF60078FE58 /* http_auth_cache.cc in Sources */,
0435A47A0E8DD6F300E4DF08 /* http_auth_handler.cc in Sources */,
0435A4800E8DD73600E4DF08 /* http_auth_handler_basic.cc in Sources */,
0435A48F0E8DD74B00E4DF08 /* http_auth_handler_digest.cc in Sources */,
@@ -1489,6 +1491,7 @@
821F21300E5CD746003C7E38 /* http_response_headers.cc in Sources */,
7B85042F0E5B2E4900730B43 /* http_util.cc in Sources */,
821F207F0E5CD3C6003C7E38 /* http_vary_data.cc in Sources */,
+ A50055FF0EBF8018007B0A90 /* listen_socket.cc in Sources */,
7B8504320E5B2E4900730B43 /* mapped_file_posix.cc in Sources */,
7B8504330E5B2E4900730B43 /* mem_backend_impl.cc in Sources */,
7B8504340E5B2E4900730B43 /* mem_entry_impl.cc in Sources */,
@@ -1512,6 +1515,7 @@
7B8504410E5B2E9600730B43 /* stats.cc in Sources */,
DFEE18270E882E3600666107 /* stats_histogram.cc in Sources */,
E47E933F0E8924DC00CA613E /* tcp_client_socket_libevent.cc in Sources */,
+ A50055FE0EBF800D007B0A90 /* telnet_server.cc in Sources */,
7B8504450E5B2E9600730B43 /* trace.cc in Sources */,
821F23670E5E0D2F003C7E38 /* upload_data.cc in Sources */,
E4CE9C070E8BFF0700D5378C /* upload_data_stream.cc in Sources */,
@@ -1519,6 +1523,7 @@
821F23C30E5E105E003C7E38 /* url_request_about_job.cc in Sources */,
7B85044A0E5B2E9600730B43 /* url_request_error_job.cc in Sources */,
E4005E3A0E9FA63B0055B38E /* url_request_file_job.cc in Sources */,
+ E45449720ECA0264000DFA6E /* url_request_filter.cc in Sources */,
821F236C0E5E0EF8003C7E38 /* url_request_http_job.cc in Sources */,
821F23CA0E5E106B003C7E38 /* url_request_job.cc in Sources */,
B5F622260E805FC40076681A /* url_request_job_manager.cc in Sources */,
@@ -1529,9 +1534,6 @@
821F20A50E5CD414003C7E38 /* url_request_view_cache_job.cc in Sources */,
82113BBD0E892E5800E3848F /* x509_certificate.cc in Sources */,
827E139D0E81611D00183614 /* x509_certificate_mac.cc in Sources */,
- A50055FE0EBF800D007B0A90 /* telnet_server.cc in Sources */,
- A50055FF0EBF8018007B0A90 /* listen_socket.cc in Sources */,
- 04E7BD550EC4ECF60078FE58 /* http_auth_cache.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj b/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj
index d69447c..5c5adbc 100644
--- a/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj
+++ b/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj
@@ -39,6 +39,7 @@
82F39D490E7EFDAA00785E15 /* libjscre.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B82059A0E770291008F45CF /* libjscre.a */; };
82F39D4A0E7EFDAA00785E15 /* libv8.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B82059C0E770291008F45CF /* libv8.a */; };
E450637E0E4100740025A81A /* test_shell_request_context.cc in Sources */ = {isa = PBXBuildFile; fileRef = E450637D0E4100740025A81A /* test_shell_request_context.cc */; };
+ E45449370EC9FD15000DFA6E /* test_shell.cc in Sources */ = {isa = PBXBuildFile; fileRef = E45449360EC9FD15000DFA6E /* test_shell.cc */; };
E45628E70E26B4FE005E4685 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
E45628E80E26B4FE005E4685 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
E45628E90E26B4FE005E4685 /* test_shell in Resources */ = {isa = PBXBuildFile; fileRef = 824CB6100DAFEF14000C5DDE /* test_shell */; };
@@ -655,6 +656,7 @@
ABD16F700DC6CBDF0013D3AA /* base.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = base.xcodeproj; path = base/base.xcodeproj; sourceTree = "<group>"; };
E450637C0E4100740025A81A /* test_shell_request_context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = test_shell_request_context.h; sourceTree = "<group>"; };
E450637D0E4100740025A81A /* test_shell_request_context.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_shell_request_context.cc; sourceTree = "<group>"; };
+ E45449360EC9FD15000DFA6E /* test_shell.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_shell.cc; sourceTree = "<group>"; };
E456293E0E26B4FE005E4685 /* TestShell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestShell.app; sourceTree = BUILT_PRODUCTS_DIR; };
E45629460E26B5A7005E4685 /* net.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = net.xcodeproj; path = net/net.xcodeproj; sourceTree = "<group>"; };
E456295B0E26B5F8005E4685 /* bzip2.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = bzip2.xcodeproj; path = third_party/bzip2/bzip2.xcodeproj; sourceTree = "<group>"; };
@@ -1024,6 +1026,7 @@
E45629680E26B64D005E4685 /* simple_resource_loader_bridge.h */,
AB351E2E0DC7B290002F427A /* test_navigation_controller.cc */,
AB351E2F0DC7B290002F427A /* test_navigation_controller.h */,
+ E45449360EC9FD15000DFA6E /* test_shell.cc */,
ABA9CAE80DBC521D00CB1EFB /* test_shell.h */,
ABA9CAE90DBC521D00CB1EFB /* test_shell_mac.mm */,
E450637D0E4100740025A81A /* test_shell_request_context.cc */,
@@ -1539,6 +1542,7 @@
53E50D280ECA1B21001784B4 /* simple_clipboard_impl.cc in Sources */,
E456296A0E26B64D005E4685 /* simple_resource_loader_bridge.cc in Sources */,
E45629190E26B4FE005E4685 /* test_navigation_controller.cc in Sources */,
+ E45449370EC9FD15000DFA6E /* test_shell.cc in Sources */,
E456291A0E26B4FE005E4685 /* test_shell_mac.mm in Sources */,
E450637E0E4100740025A81A /* test_shell_request_context.cc in Sources */,
E456290C0E26B4FE005E4685 /* test_shell_switches.cc in Sources */,
diff --git a/webkit/tools/test_shell/mac/main.mm b/webkit/tools/test_shell/mac/main.mm
index 44e3b58..f0148fd 100644
--- a/webkit/tools/test_shell/mac/main.mm
+++ b/webkit/tools/test_shell/mac/main.mm
@@ -27,9 +27,13 @@
static char g_currentTestName[PATH_MAX];
+static const wchar_t* kStatsFile = L"testshell";
+static int kStatsFileThreads = 20;
+static int kStatsFileCounters = 100;
+
// Extracts the name of the test from the given path and sets the test name
// global.
-void SetCurrentTestName(char* path) {
+static void SetCurrentTestName(char* path) {
char* lastSlash = strrchr(path, '/');
if (lastSlash) {
++lastSlash;
@@ -41,7 +45,49 @@ void SetCurrentTestName(char* path) {
g_currentTestName[PATH_MAX-1] = '\0';
}
+// The application delegate, used to hook application termination so that we
+// can kill the TestShell object and do some other app-wide cleanup. Once we
+// go into the run-loop, we never come back to main.
+@interface TestShellAppDelegate : NSObject {
+ @private
+ TestShell* shell_; // strong
+}
+- (id)initWithShell:(TestShell*)shell;
+@end
+
+@implementation TestShellAppDelegate
+- (id)initWithShell:(TestShell*)shell {
+ if ((self = [super init])) {
+ shell_ = shell;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ // Flush any remaining messages. This ensures that any accumulated
+ // Task objects get destroyed before we exit, which avoids noise in
+ // purify leak-test results.
+ MessageLoop::current()->RunAllPending();
+
+ StatsTable* table = StatsTable::current();
+ StatsTable::set_current(NULL);
+ delete table;
+ delete shell_;
+
+ TestShell::ShutdownTestShell();
+ TestShell::CleanupLogging();
+
+ [super dealloc];
+}
+
+// Called because we're the NSApp's delegate. Destroy ourselves which forces
+// shutdown cleanup to be called.
+- (void)applicationWillTerminate:(id)sender {
+ // commit suicide.
+ [self release];
+}
+@end
int main(const int argc, const char *argv[]) {
InitWebCoreSystemInterface();
@@ -115,6 +161,14 @@ int main(const int argc, const char *argv[]) {
CommandLine::AppendSwitch(&javascript_flags, L"expose-gc");
webkit_glue::SetJavaScriptFlags(javascript_flags);
+ // Load and initialize the stats table (one per process, so that multiple
+ // instances don't interfere with each other)
+ wchar_t statsfile[64];
+ swprintf(statsfile, 64, L"%ls-%d", kStatsFile, getpid());
+ StatsTable *table =
+ new StatsTable(kStatsFile, kStatsFileThreads, kStatsFileCounters);
+ StatsTable::set_current(table);
+
#if NOT_YET
//TODO: record/playback modes
bool playback_mode =
@@ -210,6 +264,13 @@ int main(const int argc, const char *argv[]) {
base::MemoryDebug::SetMemoryInUseEnabled(true);
base::MemoryDebug::DumpAllMemoryInUse();
}
+
+ // Set up our app delegate so we can tear down the TestShell object when
+ // necessary. |delegate| takes ownership of |shell|, and will clean itself
+ // up when it receives the notification that the app is terminating.
+ TestShellAppDelegate* delegate = [[TestShellAppDelegate alloc]
+ initWithShell:shell];
+ [[NSApplication sharedApplication] setDelegate:delegate];
if (layout_test_mode) {
// If we die during tests, we don't want to be spamming the user's crash
@@ -267,8 +328,6 @@ int main(const int argc, const char *argv[]) {
base::EventRecorder::current()->StopPlayback();
#endif
}
- TestShell::ShutdownTestShell();
- TestShell::CleanupLogging();
[pool release];
return 0;
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 02e7df5..e173f84 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -32,7 +32,11 @@
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_navigation_controller.h"
+#if defined(OS_MACOSX)
+#include "webkit/glue/bogus_webkit_strings.h"
+#elif defined(OS_WIN) || defined(OS_LINUX)
#include "webkit_strings.h"
+#endif
#include "SkBitmap.h"
@@ -208,8 +212,13 @@ void TestShell::ResetWebPreferences() {
// 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.
+#if defined(OS_MACOSX)
+ web_prefs_->cursive_font_family = L"Apple Chancery";
+ web_prefs_->fantasy_font_family = L"Papyrus";
+#else
web_prefs_->cursive_font_family = L"Comic Sans MS";
web_prefs_->fantasy_font_family = L"Impact";
+#endif
web_prefs_->default_encoding = L"ISO-8859-1";
web_prefs_->default_font_size = 16;
web_prefs_->default_fixed_font_size = 13;
@@ -410,7 +419,7 @@ std::string GetDataResource(int resource_id) {
}
}
-SkBitmap* GetBitmapResource(int resource_id) {
+GlueBitmap GetBitmapResource(int resource_id) {
return NULL;
}
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index dafb530..71606ba 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -45,10 +45,6 @@
// Global Variables:
-// Default timeout for page load when running non-interactive file
-// tests, in ms.
-const int kDefaultFileTestTimeoutMillisecs = 10 * 1000;
-
// Content area size for newly created windows.
const int kTestWindowWidth = 800;
const int kTestWindowHeight = 600;
@@ -62,98 +58,14 @@ const int kSVGTestWindowHeight = 360;
const int kTestWindowXLocation = -14000;
const int kTestWindowYLocation = -14000;
-static const wchar_t* kStatsFile = L"testshell";
-static int kStatsFileThreads = 20;
-static int kStatsFileCounters = 100;
-
// Define static member variables
-WindowList* TestShell::window_list_;
-WebPreferences* TestShell::web_prefs_;
-bool TestShell::interactive_ = true;
-int TestShell::file_test_timeout_ms_ = kDefaultFileTestTimeoutMillisecs;
base::LazyInstance <std::map<gfx::WindowHandle, TestShell *> >
TestShell::window_map_(base::LINKER_INITIALIZED);
+// Mac-specific stuff to do when the dtor is called. Nothing to do in our
+// case.
+void TestShell::PlatformCleanUp() {
-TestShell::TestShell()
- : m_mainWnd(NULL),
- m_editWnd(NULL),
- m_webViewHost(NULL),
- m_popupHost(NULL),
- m_focusedWidgetHost(NULL),
- layout_test_controller_(new LayoutTestController(this)),
- event_sending_controller_(new EventSendingController(this)),
- text_input_controller_(new TextInputController(this)),
- navigation_controller_(new TestNavigationController(this)),
- delegate_(new TestWebViewDelegate(this)),
- test_is_preparing_(false),
- test_is_pending_(false),
- dump_stats_table_on_exit_(false) {
- // load and initialize the stats table (one per process, so that multiple
- // instances don't interfere with each other)
- wchar_t statsfile[64];
- swprintf(statsfile, 64, L"%ls-%d", kStatsFile, getpid());
-
- StatsTable* table = new StatsTable(statsfile, kStatsFileThreads,
- kStatsFileCounters);
- StatsTable::set_current(table);
-}
-
-TestShell::~TestShell() {
- window_map_.Get().erase(m_mainWnd);
-
- if (dump_stats_table_on_exit_) {
- // Dump the stats table.
- printf("<stats>\n");
- StatsTable* table = StatsTable::current();
- if (table != NULL) {
- int counter_max = table->GetMaxCounters();
- for (int index = 0; index < counter_max; index++) {
- std::string name(WideToUTF8(table->GetRowName(index)));
- if (name.length() > 0) {
- int value = table->GetRowValue(index);
- printf("%s:\t%d\n", name.c_str(), value);
- }
- }
- }
- printf("</stats>\n");
- }
-}
-
-// All fatal log messages (e.g. DCHECK failures) imply unit test failures
-static void UnitTestAssertHandler(const std::string& str) {
- FAIL() << str;
-}
-
-// static
-void TestShell::InitLogging(bool suppress_error_dialogs,
- bool running_layout_tests) {
- if (suppress_error_dialogs) {
- logging::SetLogAssertHandler(UnitTestAssertHandler);
- }
-
- // Only log to a file if we're running layout tests. This prevents debugging
- // output from disrupting whether or not we pass.
- logging::LoggingDestination destination =
- logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG;
- if (running_layout_tests)
- destination = logging::LOG_ONLY_TO_FILE;
-
- // We might have multiple test_shell processes going at once
- char log_filename_template[] = "/tmp/test_shell_XXXXXX";
- char* log_filename = mktemp(log_filename_template);
- logging::InitLogging(log_filename,
- destination,
- logging::LOCK_LOG_FILE,
- logging::DELETE_OLD_LOG_FILE);
-
- // we want process and thread IDs because we may have multiple processes
- logging::SetLogItems(true, true, false, true);
-}
-
-// static
-void TestShell::CleanupLogging() {
- logging::CloseLogFile();
}
// static
@@ -166,39 +78,6 @@ void TestShell::InitializeTestShell(bool interactive) {
ResetWebPreferences();
}
-// static
-void TestShell::ResetWebPreferences() {
- DCHECK(web_prefs_);
-
- // Match the settings used by Mac DumpRenderTree.
- if (web_prefs_) {
- 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";
- web_prefs_->cursive_font_family = L"Apple Chancery";
- web_prefs_->fantasy_font_family = L"Papyrus";
- 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;
- }
-}
-
-// static
-void TestShell::ShutdownTestShell() {
- delete window_list_;
- delete TestShell::web_prefs_;
-}
-
NSButton* MakeTestButton(NSRect* rect, NSString* title, NSView* parent) {
NSButton* button = [[NSButton alloc] initWithFrame:*rect];
[button setTitle:title];
@@ -391,45 +270,13 @@ void TestShell::WaitTestFinished() {
[thread release];
}
-void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) {
- delegate_->Show(webview, disposition);
-}
-
-void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
- if (interactive_) {
- if (enable) {
- // ::SetFocus(host->window_handle());
- } else {
- // if (GetFocus() == host->window_handle())
- // ::SetFocus(NULL);
- }
- } else {
- if (enable) {
- if (m_focusedWidgetHost != host) {
- if (m_focusedWidgetHost)
- m_focusedWidgetHost->webwidget()->SetFocus(false);
- host->webwidget()->SetFocus(enable);
- m_focusedWidgetHost = host;
- }
- } else {
- if (m_focusedWidgetHost == host) {
- host->webwidget()->SetFocus(enable);
- m_focusedWidgetHost = NULL;
- }
- }
- }
-}
-
-void TestShell::BindJSObjectsToWindow(WebFrame* frame) {
- // Only bind the test classes if we're running tests.
- if (!interactive_) {
- layout_test_controller_->BindToJavascript(frame,
- L"layoutTestController");
- event_sending_controller_->BindToJavascript(frame,
- L"eventSender");
- text_input_controller_->BindToJavascript(frame,
- L"textInputController");
- }
+void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) {
+#if 0
+ if (enable)
+ ::SetFocus(host->window_handle());
+ else if (::GetFocus() == host->window_handle())
+ ::SetFocus(NULL);
+#endif
}
// static*
@@ -452,19 +299,6 @@ void TestShell::DestroyWindow(gfx::WindowHandle windowHandle) {
[windowHandle performClose:nil];
}
-WebView* TestShell::CreateWebView(WebView* webview) {
- // If we're running layout tests, only open a new window if the test has
- // called layoutTestController.setCanOpenWindows()
- if (!interactive_ && !layout_test_controller_->CanOpenWindows())
- return NULL;
-
- TestShell* new_win;
- if (!CreateNewWindow(std::wstring(), &new_win))
- return NULL;
-
- return new_win->webView();
-}
-
WebWidget* TestShell::CreatePopupWidget(WebView* webview) {
DCHECK(!m_popupHost);
m_popupHost = WebWidgetHost::Create(NULL, delegate_.get());
@@ -478,10 +312,6 @@ void TestShell::ClosePopup() {
m_popupHost = NULL;
}
-void TestShell::SizeToDefault() {
- SizeTo(kTestWindowWidth, kTestWindowHeight);
-}
-
void TestShell::SizeTo(int width, int height) {
// WebViewHost::Create() sets the HTML content rect to start 32 pixels below
// the top of the window to account for the "toolbar". We need to match that
@@ -650,11 +480,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)
@@ -684,51 +509,6 @@ void TestShell::LoadURLForFrame(const wchar_t* url,
-1, GURL(urlString), std::wstring(), frame_string));
}
-bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) {
- const TestNavigationEntry& test_entry =
- *static_cast<const TestNavigationEntry*>(&entry);
-
- 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 (!test_entry.GetTargetFrame().empty())
- frame = webView()->GetFrameWithName(test_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);
-}
-
bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
std::wstring* result)
{
@@ -758,11 +538,6 @@ static void WriteTextToFile(const std::string& data,
fclose(fp);
}
-std::wstring TestShell::GetDocumentText()
-{
- return webkit_glue::DumpDocumentText(webView()->GetMainFrame());
-}
-
void TestShell::DumpDocumentText()
{
std::wstring file_path;
@@ -785,10 +560,6 @@ void TestShell::DumpRenderTree()
WideToUTF8(file_path));
}
-void TestShell::Reload() {
- navigation_controller_->Reload();
-}
-
/* static */
std::string TestShell::RewriteLocalUrl(const std::string& url) {
// Convert file:///tmp/LayoutTests urls to the actual location on disk.
@@ -817,28 +588,6 @@ 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::string &file_path,
- std::string* mime_type) {
- return net::GetMimeTypeFromFile(UTF8ToWide(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) {
NSString* idString = [NSString stringWithFormat:@"%d", message_id];
NSString* localString = NSLocalizedString(idString, @"");
@@ -846,63 +595,11 @@ std::wstring GetLocalizedString(int message_id) {
return UTF8ToWide([localString UTF8String]);
}
-std::string GetDataResource(int resource_id) {
- if (resource_id == IDR_BROKENIMAGE) {
- // Use webkit's broken image icon (16x16)
- static std::string broken_image_data;
- if (broken_image_data.empty()) {
- std::wstring path;
- PathService::Get(base::DIR_SOURCE_ROOT, &path);
- file_util::AppendToPath(&path, L"webkit");
- file_util::AppendToPath(&path, L"tools");
- file_util::AppendToPath(&path, L"test_shel");
- file_util::AppendToPath(&path, L"resources");
- file_util::AppendToPath(&path, L"missingImage.gif");
- bool success = file_util::ReadFileToString(path, &broken_image_data);
- if (!success) {
- LOG(FATAL) << "Failed reading: " << path;
- }
- }
- return broken_image_data;
- } else if (resource_id == IDR_FEED_PREVIEW) {
- // It is necessary to return a feed preview template that contains
- // a {{URL}} substring where the feed URL should go; see the code
- // that computes feed previews in feed_preview.cc:MakeFeedPreview.
- // This fixes issue #932714.
- return std::string("Feed preview for {{URL}}");
- } else {
- return std::string();
- }
-}
-
NSCursor* LoadCursor(int cursor_id) {
// TODO(port): add some more options here
return [NSCursor arrowCursor];
}
-CGImageRef GetBitmapResource(int resource_id) {
- return NULL;
-}
-
-bool GetApplicationDirectory(std::string* path) {
- NSString* bundle_path = [[NSBundle mainBundle] bundlePath];
- if (!bundle_path)
- return false;
- bundle_path = [bundle_path stringByDeletingLastPathComponent];
- *path = [bundle_path UTF8String];
- return true;
-}
-
-GURL GetInspectorURL() {
- // TODO(port): is this right?
- NSLog(@"GetInspectorURL");
- return GURL("test-shell-resource://inspector/inspector.html");
-}
-
-std::string GetUIResourceProtocol() {
- return "test-shell-resource";
-}
-
bool GetInspectorHTMLPath(std::string* path) {
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
if (!resource_path)
@@ -912,30 +609,10 @@ bool GetInspectorHTMLPath(std::string* path) {
return true;
}
-bool GetExeDirectory(std::string* path) {
- NSString* executable_path = [[NSBundle mainBundle] executablePath];
- if (!executable_path)
- return false;
- *path = [executable_path UTF8String];
- return true;
-}
-
-bool SpellCheckWord(const char* 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 false; // NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins);
}
-bool IsPluginRunningInRendererProcess() {
- return true;
-}
-
ScreenInfo GetScreenInfo(gfx::ViewHandle window) {
// This should call GetScreenInfoHelper, which should be implemented in
// webkit_glue_mac.mm
@@ -947,18 +624,6 @@ bool DownloadUrl(const std::string& url, NSWindow* caller_window) {
return false;
}
-bool GetPluginFinderURL(std::string* plugin_finder_url) {
- return false;
-}
-
-bool IsDefaultPluginEnabled() {
- return false;
-}
-
-std::wstring GetWebKitLocale() {
- return L"en-US";
-}
-
void DidLoadPlugin(const std::string& filename) {
}
@@ -966,31 +631,3 @@ void DidUnloadPlugin(const std::string& filename) {
}
} // namespace webkit_glue
-
-// These are here ONLY to satisfy link errors until we reinstate the ObjC
-// bindings into WebCore.
-
-@interface DOMRange : NSObject
-@end
-@implementation DOMRange
-@end
-
-@interface DOMDocumentFragment : NSObject
-@end
-@implementation DOMDocumentFragment
-@end
-
-@interface DOMNode : NSObject
-@end
-@implementation DOMNode
-@end
-
-@interface DOMElement : NSObject
-@end
-@implementation DOMElement
-@end
-
-@interface DOMCSSStyleDeclaration : NSObject
-@end
-@implementation DOMCSSStyleDeclaration
-@end