summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 17:51:20 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 17:51:20 +0000
commita48146712aa765290165d2425d02518f14e22cf4 (patch)
tree0e1946292faea4359a9ec20f93f879d32a2ba78b
parenta8f643b401ec655adbe20d98dc862f168b25b17a (diff)
downloadchromium_src-a48146712aa765290165d2425d02518f14e22cf4.zip
chromium_src-a48146712aa765290165d2425d02518f14e22cf4.tar.gz
chromium_src-a48146712aa765290165d2425d02518f14e22cf4.tar.bz2
Port some test_shell_tests, and platform cleanup for more of them.
Many of these files that I don't added to the build would even compile and link, but don't yet pass with current test_shell on Linux. They just hang. Patch from Paweł Hajdan jr <phajdan.jr@gmail.com> on http://codereview.chromium.org/9417 Review URL: http://codereview.chromium.org/9641 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4892 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/glue/context_menu_unittest.cc4
-rw-r--r--webkit/glue/dom_operations.cc29
-rw-r--r--webkit/glue/dom_operations.h20
-rw-r--r--webkit/glue/dom_operations_unittest.cc20
-rw-r--r--webkit/glue/dom_serializer_unittest.cc24
-rw-r--r--webkit/glue/mimetype_unittest.cc6
-rw-r--r--webkit/glue/searchable_form_data.cc6
-rw-r--r--webkit/glue/webframe_impl.cc7
-rw-r--r--webkit/tools/test_shell/SConscript4
9 files changed, 69 insertions, 51 deletions
diff --git a/webkit/glue/context_menu_unittest.cc b/webkit/glue/context_menu_unittest.cc
index 63860b5..3508a05 100644
--- a/webkit/glue/context_menu_unittest.cc
+++ b/webkit/glue/context_menu_unittest.cc
@@ -36,7 +36,7 @@ TEST_F(ContextMenuCapturing, ContextMenuCapturing) {
WebViewDelegate* raw_delegate = test_shell_->webView()->GetDelegate();
TestWebViewDelegate* test_delegate = static_cast<TestWebViewDelegate*>(raw_delegate);
test_delegate->clear_captured_context_menu_events();
- EXPECT_EQ(0, test_delegate->captured_context_menu_events().size());
+ EXPECT_EQ(0U, test_delegate->captured_context_menu_events().size());
std::wstring test_url = GetTestURL(iframes_data_dir_, L"testiframe.html");
test_shell_->LoadURL(test_url.c_str());
@@ -62,6 +62,6 @@ TEST_F(ContextMenuCapturing, ContextMenuCapturing) {
mouse_event.type = WebInputEvent::MOUSE_UP;
webview->HandleInputEvent(&mouse_event);
- EXPECT_EQ(1, test_delegate->captured_context_menu_events().size());
+ EXPECT_EQ(1U, test_delegate->captured_context_menu_events().size());
}
diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc
index fe039a7..9e15d8a 100644
--- a/webkit/glue/dom_operations.cc
+++ b/webkit/glue/dom_operations.cc
@@ -21,6 +21,7 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "HTMLInputElement.h"
#include "HTMLLinkElement.h"
#include "HTMLMetaElement.h"
+#include "HTMLOptionElement.h"
#include "HTMLNames.h"
#include "KURL.h"
MSVC_POP_WARNING();
@@ -30,9 +31,8 @@ MSVC_POP_WARNING();
// first.
#include "webkit/glue/autocomplete_input_listener.h"
-#include "webkit/glue/dom_operations.h"
-
#include "base/string_util.h"
+#include "webkit/glue/dom_operations.h"
#include "webkit/glue/form_data.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/password_autocomplete_listener.h"
@@ -152,6 +152,16 @@ void GetAllSavableResourceLinksForFrame(WebFrameImpl* current_frame,
}
}
+template <class HTMLNodeType>
+HTMLNodeType* CastHTMLElement(WebCore::Node* node,
+ const WebCore::QualifiedName& name) {
+ if (node->isHTMLElement() &&
+ static_cast<typename WebCore::HTMLElement*>(node)->hasTagName(name)) {
+ return static_cast<HTMLNodeType*>(node);
+ }
+ return NULL;
+}
+
} // namespace
namespace webkit_glue {
@@ -443,6 +453,21 @@ void FillPasswordForm(WebView* view,
}
}
+WebCore::HTMLLinkElement* CastToHTMLLinkElement(WebCore::Node* node) {
+ return CastHTMLElement<WebCore::HTMLLinkElement>(node,
+ WebCore::HTMLNames::linkTag);
+}
+
+WebCore::HTMLMetaElement* CastToHTMLMetaElement(WebCore::Node* node) {
+ return CastHTMLElement<WebCore::HTMLMetaElement>(node,
+ WebCore::HTMLNames::metaTag);
+}
+
+WebCore::HTMLOptionElement* CastToHTMLOptionElement(WebCore::Node* node) {
+ return CastHTMLElement<WebCore::HTMLOptionElement>(node,
+ WebCore::HTMLNames::optionTag);
+}
+
WebFrameImpl* GetWebFrameImplFromElement(WebCore::Element* element,
bool* is_frame_element) {
*is_frame_element = false;
diff --git a/webkit/glue/dom_operations.h b/webkit/glue/dom_operations.h
index 9d17df6..20d5585 100644
--- a/webkit/glue/dom_operations.h
+++ b/webkit/glue/dom_operations.h
@@ -20,6 +20,9 @@ namespace WebCore {
class AtomicString;
class Document;
class Element;
+class HTMLLinkElement;
+class HTMLMetaElement;
+class HTMLOptionElement;
class Node;
class QualifiedName;
class String;
@@ -60,18 +63,11 @@ bool FillForm(WebView* view, const FormData& data);
void FillPasswordForm(WebView* view,
const PasswordFormDomManager::FillData& data);
-// If node is an HTML node with a tag name of name it is casted to HTMLNodeType
-// and returned. If node is not an HTML node or the tag name is not name
-// NULL is returned.
-template <class HTMLNodeType>
-HTMLNodeType* CastHTMLElement(WebCore::Node* node,
- const WebCore::QualifiedName& name) {
- if (node->isHTMLElement() &&
- static_cast<WebCore::HTMLElement*>(node)->hasTagName(name)) {
- return static_cast<HTMLNodeType*>(node);
- }
- return NULL;
-}
+// If node is an HTML node with a tag name of name it is casted and returned.
+// If node is not an HTML node or the tag name is not name NULL is returned.
+WebCore::HTMLLinkElement* CastToHTMLLinkElement(WebCore::Node* node);
+WebCore::HTMLMetaElement* CastToHTMLMetaElement(WebCore::Node* node);
+WebCore::HTMLOptionElement* CastToHTMLOptionElement(WebCore::Node* node);
// If element is HTML:IFrame or HTML:Frame, then return the WebFrameImpl
// object corresponding to the content frame, otherwise return NULL.
diff --git a/webkit/glue/dom_operations_unittest.cc b/webkit/glue/dom_operations_unittest.cc
index 355c914..2ef4418 100644
--- a/webkit/glue/dom_operations_unittest.cc
+++ b/webkit/glue/dom_operations_unittest.cc
@@ -55,7 +55,7 @@ void DomOperationsTests::GetSavableResourceLinksForPage(
&referrers_list,
&frames_list);
- GURL main_page_gurl(file_wurl);
+ GURL main_page_gurl(WideToUTF8(file_wurl));
ASSERT_TRUE(webkit_glue::GetAllSavableResourceLinksForCurrentPage(
test_shell_->webView(), main_page_gurl, &result));
// Check all links of sub-resource
@@ -80,20 +80,20 @@ TEST_F(DomOperationsTests, GetSavableResourceLinksWithPageHasValidLinks) {
std::wstring page_file_path = data_dir_;
file_util::AppendToPath(&page_file_path, L"dom_serializer");
- const wchar_t* expected_sub_resource_links[] = {
- L"file:///c:/yt/css/base_all-vfl36460.css",
- L"file:///c:/yt/js/base_all_with_bidi-vfl36451.js",
- L"file:///c:/yt/img/pixel-vfl73.gif"
+ const char* expected_sub_resource_links[] = {
+ "file:///c:/yt/css/base_all-vfl36460.css",
+ "file:///c:/yt/js/base_all_with_bidi-vfl36451.js",
+ "file:///c:/yt/img/pixel-vfl73.gif"
};
const wchar_t* expected_frame_links[] = {
L"youtube_1.htm",
L"youtube_2.htm"
};
// Add all expected links of sub-resource to expected set.
- for (int i = 0; i < arraysize(expected_sub_resource_links); ++i)
+ for (size_t i = 0; i < arraysize(expected_sub_resource_links); ++i)
expected_resources_set.insert(GURL(expected_sub_resource_links[i]));
// Add all expected links of frame to expected set.
- for (int i = 0; i < arraysize(expected_frame_links); ++i) {
+ for (size_t i = 0; i < arraysize(expected_frame_links); ++i) {
std::wstring expected_frame_url = page_file_path;
file_util::AppendToPath(&expected_frame_url, expected_frame_links[i]);
expected_resources_set.insert(
@@ -116,7 +116,7 @@ TEST_F(DomOperationsTests, GetSavableResourceLinksWithPageHasInvalidLinks) {
L"youtube_2.htm"
};
// Add all expected links of frame to expected set.
- for (int i = 0; i < arraysize(expected_frame_links); ++i) {
+ for (size_t i = 0; i < arraysize(expected_frame_links); ++i) {
std::wstring expected_frame_url = page_file_path;
file_util::AppendToPath(&expected_frame_url, expected_frame_links[i]);
expected_resources_set.insert(
@@ -133,7 +133,7 @@ TEST_F(DomOperationsTests, ParseIconSizes) {
const std::wstring input;
const bool expected_result;
const bool is_any;
- const int expected_size_count;
+ const size_t expected_size_count;
const int width1;
const int height1;
const int width2;
@@ -160,7 +160,7 @@ TEST_F(DomOperationsTests, ParseIconSizes) {
{ L" 10x11 ", true, false, 1, 10, 11, 0, 0 },
{ L" 10x11 1x2", true, false, 2, 10, 11, 1, 2 },
};
- for (size_t i = 0; i < arraysize(data); ++i) {
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
bool is_any;
std::vector<gfx::Size> sizes;
const bool result =
diff --git a/webkit/glue/dom_serializer_unittest.cc b/webkit/glue/dom_serializer_unittest.cc
index 6c0f091..99d0fdc 100644
--- a/webkit/glue/dom_serializer_unittest.cc
+++ b/webkit/glue/dom_serializer_unittest.cc
@@ -22,17 +22,17 @@ MSVC_PUSH_WARNING_LEVEL(0);
MSVC_POP_WARNING();
#undef LOG
-#include "base/hash_tables.h"
#include "base/file_util.h"
+#include "base/hash_tables.h"
#include "base/string_util.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request_context.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/dom_serializer.h"
#include "webkit/glue/dom_serializer_delegate.h"
-#include "webkit/glue/webview.h"
#include "webkit/glue/webframe.h"
#include "webkit/glue/webframe_impl.h"
+#include "webkit/glue/webview.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_shell_test.h"
@@ -134,7 +134,7 @@ class DomSerializerTests : public TestShellTest,
// Find corresponding WebFrameImpl according to page_url.
WebFrameImpl* web_frame =
webkit_glue::GetWebFrameImplFromWebViewForSpecificURL(
- test_shell_->webView(), GURL(page_url));
+ test_shell_->webView(), GURL(WideToUTF8(page_url)));
ASSERT_TRUE(web_frame != NULL);
// Add input file URl to links_.
links_.push_back(page_url);
@@ -258,7 +258,7 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithDocType) {
ASSERT_TRUE(HasSerializedFrame(page_url));
const std::string& serialized_contents =
GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(page_url),
+ LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
web_frame->frame()->loader()->encoding());
// Make sure serialized contents still have document type.
web_frame =
@@ -290,7 +290,7 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithoutDocType) {
ASSERT_TRUE(HasSerializedFrame(page_url));
const std::string& serialized_contents =
GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(page_url),
+ LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
web_frame->frame()->loader()->encoding());
// Make sure serialized contents do not have document type.
web_frame =
@@ -391,7 +391,7 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithNoMetaCharsetInOriginalDoc) {
ASSERT_TRUE(HasSerializedFrame(page_url));
const std::string& serialized_contents =
GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(page_url),
+ LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
web_frame->frame()->loader()->encoding());
// Make sure the first child of HEAD element is META which has charset
// declaration in serialized contents.
@@ -459,7 +459,7 @@ TEST_F(DomSerializerTests,
ASSERT_TRUE(HasSerializedFrame(page_url));
const std::string& serialized_contents =
GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(page_url),
+ LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
web_frame->frame()->loader()->encoding());
// Make sure only first child of HEAD element is META which has charset
// declaration in serialized contents.
@@ -614,7 +614,7 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) {
}
// Each link is relative link.
if (value) {
- GURL link(webkit_glue::StringToStdWString(value->string()).c_str());
+ GURL link(WideToUTF8(webkit_glue::StringToStdWString(value->string())));
ASSERT_TRUE(link.scheme().empty());
}
}
@@ -623,7 +623,7 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) {
// Make sure in original document, the base URL is not equal with the
// |path_dir_url|.
GURL original_base_url(
- webkit_glue::StringToStdWString(doc->baseURL()).c_str());
+ WideToUTF8(webkit_glue::StringToStdWString(doc->baseURL())));
ASSERT_TRUE(original_base_url != path_dir_url);
// Do serialization.
@@ -633,7 +633,7 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) {
ASSERT_TRUE(HasSerializedFrame(page_url));
const std::string& serialized_contents =
GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(page_url),
+ LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
web_frame->frame()->loader()->encoding());
// Make sure all links are absolute URLs and doc there are some number of
@@ -665,7 +665,7 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) {
}
// Each link is absolute link.
if (value) {
- GURL link(webkit_glue::StringToStdWString(value->string()).c_str());
+ GURL link(WideToUTF8(webkit_glue::StringToStdWString(value->string())));
ASSERT_FALSE(link.scheme().empty());
}
}
@@ -674,6 +674,6 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) {
ASSERT_TRUE(new_base_tag_count == original_base_tag_count + 1);
// Make sure in new document, the base URL is equal with the |path_dir_url|.
GURL new_base_url(
- webkit_glue::StringToStdWString(doc->baseURL()).c_str());
+ WideToUTF8(webkit_glue::StringToStdWString(doc->baseURL())));
ASSERT_TRUE(new_base_url == path_dir_url);
}
diff --git a/webkit/glue/mimetype_unittest.cc b/webkit/glue/mimetype_unittest.cc
index 5f21b97..bbbf0f6 100644
--- a/webkit/glue/mimetype_unittest.cc
+++ b/webkit/glue/mimetype_unittest.cc
@@ -49,7 +49,7 @@ TEST_F(MimeTypeTests, MimeTypeTests) {
"text/rtf",
"application/x-javascript",
};
- for (int i = 0; i < arraysize(plain_text); ++i) {
+ for (size_t i = 0; i < arraysize(plain_text); ++i) {
CheckMimeType(plain_text[i], expected_src);
}
@@ -60,7 +60,7 @@ TEST_F(MimeTypeTests, MimeTypeTests) {
"text/xsl",
"application/xhtml+xml",
};
- for (int i = 0; i < arraysize(html_src); ++i) {
+ for (size_t i = 0; i < arraysize(html_src); ++i) {
CheckMimeType(html_src[i], L"HTML text");
}
@@ -72,7 +72,7 @@ TEST_F(MimeTypeTests, MimeTypeTests) {
"image/jpeg",
"image/bmp",
};
- for (int i = 0; i < arraysize(not_text); ++i) {
+ for (size_t i = 0; i < arraysize(not_text); ++i) {
CheckMimeType(not_text[i], L"");
test_shell_->webView()->StopLoading();
}
diff --git a/webkit/glue/searchable_form_data.cc b/webkit/glue/searchable_form_data.cc
index 420c19a..582e78c 100644
--- a/webkit/glue/searchable_form_data.cc
+++ b/webkit/glue/searchable_form_data.cc
@@ -154,8 +154,7 @@ bool IsSelectInDefaultState(WebCore::HTMLSelectElement* select) {
HTMLOptionElement* initial_selected = NULL;
while (node) {
HTMLOptionElement* option_element =
- webkit_glue::CastHTMLElement<HTMLOptionElement>(
- node, WebCore::HTMLNames::optionTag);
+ webkit_glue::CastToHTMLOptionElement(node);
if (option_element) {
if (!initial_selected)
initial_selected = option_element;
@@ -172,8 +171,7 @@ bool IsSelectInDefaultState(WebCore::HTMLSelectElement* select) {
} else {
while (node) {
HTMLOptionElement* option_element =
- webkit_glue::CastHTMLElement<HTMLOptionElement>(
- node, WebCore::HTMLNames::optionTag);
+ webkit_glue::CastToHTMLOptionElement(node);
if (option_element &&
option_element->selected() != option_element->defaultSelected()) {
return false;
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index a84a104..76ef6df 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -103,7 +103,6 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "GraphicsContext.h"
#include "HTMLHeadElement.h"
#include "HTMLLinkElement.h"
-#include "HTMLNames.h"
#include "HistoryItem.h"
#include "markup.h"
#include "Page.h"
@@ -125,6 +124,7 @@ MSVC_PUSH_WARNING_LEVEL(0);
MSVC_POP_WARNING();
#undef LOG
+
#include "base/gfx/bitmap_platform_device.h"
#include "base/gfx/platform_canvas.h"
#include "base/gfx/rect.h"
@@ -134,9 +134,9 @@ MSVC_POP_WARNING();
#include "base/string_util.h"
#include "base/time.h"
#include "net/base/net_errors.h"
+#include "webkit/glue/alt_error_page_resource_fetcher.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/glue_serialize.h"
-#include "webkit/glue/alt_error_page_resource_fetcher.h"
#include "webkit/glue/webdocumentloader_impl.h"
#include "webkit/glue/weberror_impl.h"
#include "webkit/glue/webframe_impl.h"
@@ -470,8 +470,7 @@ GURL WebFrameImpl::GetOSDDURL() const {
for (Node* child = children->firstItem(); child != NULL;
child = children->nextItem()) {
WebCore::HTMLLinkElement* link_element =
- webkit_glue::CastHTMLElement<WebCore::HTMLLinkElement>(
- child, WebCore::HTMLNames::linkTag);
+ webkit_glue::CastToHTMLLinkElement(child);
if (link_element && link_element->type() == kOSDType &&
link_element->rel() == kOSDRel && !link_element->href().isEmpty()) {
return webkit_glue::KURLToGURL(link_element->href());
diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript
index b591b8a..02b4cb5 100644
--- a/webkit/tools/test_shell/SConscript
+++ b/webkit/tools/test_shell/SConscript
@@ -156,9 +156,11 @@ test_files = [
'image_decoder_unittest.cc',
'keyboard_unittest.cc',
'layout_test_controller_unittest.cc',
+ 'node_leak_test.cc',
'run_all_tests.cc',
'test_shell_test.cc',
'$WEBKIT_DIR/glue/autocomplete_input_listener_unittest.cc',
+ '$WEBKIT_DIR/glue/bookmarklet_unittest.cc',
'$WEBKIT_DIR/glue/cpp_bound_class_unittest.cc',
'$WEBKIT_DIR/glue/cpp_variant_unittest.cc',
'$WEBKIT_DIR/glue/glue_serialize_unittest.cc',
@@ -172,10 +174,8 @@ test_files = [
if env['PLATFORM'] == 'win32':
# TODO(port): put portable files in above test_files declaration.
test_files.extend([
- 'node_leak_test.cc',
'plugin_tests.cc',
'text_input_controller_unittest.cc',
- '$WEBKIT_DIR/glue/bookmarklet_unittest.cc',
'$WEBKIT_DIR/glue/context_menu_unittest.cc',
'$WEBKIT_DIR/glue/dom_operations_unittest.cc',
'$WEBKIT_DIR/glue/dom_serializer_unittest.cc',