Commit c11e39f8 authored by rjwright@chromium.org's avatar rjwright@chromium.org

Revert of Migrate TestCommon to Chromium c++ style and remove un-used header....

Revert of Migrate TestCommon to Chromium c++ style and remove un-used header. (https://codereview.chromium.org/436133002/)

Reason for revert:
This patch removed some touch event logging in TestPlugin.cpp which broke the following layout tests

plugins/touch-events-details.html
plugins/touch-events-synthesized.html
plugins/transformed-events.html

Reverting.

Original issue's description:
> Migrate TestCommon to Chromium c++ style and remove un-used header.
> 
> Changes:
> 1) Run clang-format through source and header files.
> 2) Rename data member variables to use unix_hacker_ style.
> 3) Rename methods to use CamelCase style.
> 4) Rename file name to test_common.
> 5) Removed un-used test_common header.
> 
> BUG=331299
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287382

TBR=jochen@chromium.org,abhishek.a21@samsung.com
NOTREECHECKS=true
NOTRY=true
BUG=331299

Review URL: https://codereview.chromium.org/439973002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287468 0039d316-1c4b-4281-b951-d872f2087c98
parent 4498b51a
......@@ -175,6 +175,8 @@
'shell/renderer/shell_render_process_observer.h',
'shell/renderer/shell_render_view_observer.cc',
'shell/renderer/shell_render_view_observer.h',
'shell/renderer/test_runner/TestCommon.cpp',
'shell/renderer/test_runner/TestCommon.h',
'shell/renderer/test_runner/TestInterfaces.cpp',
'shell/renderer/test_runner/TestInterfaces.h',
'shell/renderer/test_runner/TestPlugin.cpp',
......@@ -226,8 +228,6 @@
'shell/renderer/test_runner/notification_presenter.h',
'shell/renderer/test_runner/spell_check_client.cc',
'shell/renderer/test_runner/spell_check_client.h',
'shell/renderer/test_runner/test_common.cc',
'shell/renderer/test_runner/test_common.h',
'shell/renderer/test_runner/test_runner.cc',
'shell/renderer/test_runner/test_runner.h',
'shell/renderer/test_runner/text_input_controller.cc',
......
......@@ -125,6 +125,8 @@ static_library("content_shell_lib") {
"renderer/shell_render_process_observer.h",
"renderer/shell_render_view_observer.cc",
"renderer/shell_render_view_observer.h",
"renderer/test_runner/TestCommon.cpp",
"renderer/test_runner/TestCommon.h",
"renderer/test_runner/TestInterfaces.cpp",
"renderer/test_runner/TestInterfaces.h",
"renderer/test_runner/TestPlugin.cpp",
......@@ -176,8 +178,6 @@ static_library("content_shell_lib") {
"renderer/test_runner/notification_presenter.h",
"renderer/test_runner/spell_check_client.cc",
"renderer/test_runner/spell_check_client.h",
"renderer/test_runner/test_common.cc",
"renderer/test_runner/test_common.h",
"renderer/test_runner/test_runner.cc",
"renderer/test_runner/test_runner.h",
"renderer/test_runner/text_input_controller.cc",
......
// Copyright 2014 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 "content/shell/renderer/test_runner/TestCommon.h"
namespace content {
namespace {
const char layoutTestsPattern[] = "/LayoutTests/";
const std::string::size_type layoutTestsPatternSize = sizeof(layoutTestsPattern) - 1;
const char fileUrlPattern[] = "file:/";
const char fileTestPrefix[] = "(file test):";
const char dataUrlPattern[] = "data:";
const std::string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1;
} // namespace
std::string normalizeLayoutTestURL(const std::string& url)
{
std::string result = url;
size_t pos;
if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != std::string::npos)) {
// adjust file URLs to match upstream results.
result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix);
} else if (!url.find(dataUrlPattern)) {
// URL-escape data URLs to match results upstream.
std::string path = url.substr(dataUrlPatternSize);
result.replace(dataUrlPatternSize, url.length(), path);
}
return result;
}
} // namespace content
......@@ -2,23 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_COMMON_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_COMMON_H_
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTCOMMON_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTCOMMON_H_
#include <stdio.h>
#include <string>
#include "base/compiler_specific.h"
#if defined(WIN32)
#define snprintf(str, size, ...) _snprintf_s(str, size, size, __VA_ARGS__)
#endif
namespace content {
inline bool IsASCIIAlpha(char ch) {
return (ch | 0x20) >= 'a' && (ch | 0x20) <= 'z';
}
inline bool isASCIIAlpha(char ch) { return (ch | 0x20) >= 'a' && (ch | 0x20) <= 'z'; }
inline bool IsNotASCIIAlpha(char ch) {
return !IsASCIIAlpha(ch);
}
inline bool isNotASCIIAlpha(char ch) { return !isASCIIAlpha(ch); }
std::string NormalizeLayoutTestURL(const std::string& url);
std::string normalizeLayoutTestURL(const std::string& url);
} // namespace content
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_COMMON_H_
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTCOMMON_H_
......@@ -8,8 +8,8 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/shared_memory.h"
#include "base/strings/stringprintf.h"
#include "content/public/renderer/render_thread.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTestDelegate.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
......@@ -87,10 +87,14 @@ const char* pointState(WebTouchPoint::State state)
void printTouchList(WebTestDelegate* delegate, const WebTouchPoint* points, int length)
{
for (int i = 0; i < length; ++i) {
base::StringPrintf("* %.2f, %.2f: %s\n",
points[i].position.x,
points[i].position.y,
pointState(points[i].state));
char buffer[100];
snprintf(buffer,
sizeof(buffer),
"* %.2f, %.2f: %s\n",
points[i].position.x,
points[i].position.y,
pointState(points[i].state));
delegate->printMessage(buffer);
}
}
......@@ -103,10 +107,14 @@ void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event)
printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength);
} else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebInputEvent::MouseWheel) {
const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event);
base::StringPrintf("* %d, %d\n", mouse.x, mouse.y);
char buffer[100];
snprintf(buffer, sizeof(buffer), "* %d, %d\n", mouse.x, mouse.y);
delegate->printMessage(buffer);
} else if (WebInputEvent::isGestureEventType(event.type)) {
const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(event);
base::StringPrintf("* %d, %d\n", gesture.x, gesture.y);
char buffer[100];
snprintf(buffer, sizeof(buffer), "* %d, %d\n", gesture.x, gesture.y);
delegate->printMessage(buffer);
}
}
......
......@@ -6,6 +6,7 @@
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_COLOR_CHOOSER_H_
#include "base/basictypes.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTask.h"
#include "third_party/WebKit/public/web/WebColorChooser.h"
#include "third_party/WebKit/public/web/WebColorChooserClient.h"
......
......@@ -7,7 +7,7 @@
#include <algorithm>
#include "base/logging.h"
#include "content/shell/renderer/test_runner/test_common.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "third_party/WebKit/public/platform/WebCString.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/web/WebTextCheckingResult.h"
......@@ -19,7 +19,7 @@ bool MockGrammarCheck::CheckGrammarOfString(
std::vector<blink::WebTextCheckingResult>* results) {
DCHECK(results);
base::string16 string_text = text;
if (std::find_if(string_text.begin(), string_text.end(), IsASCIIAlpha) ==
if (std::find_if(string_text.begin(), string_text.end(), isASCIIAlpha) ==
string_text.end())
return true;
......
......@@ -5,7 +5,7 @@
#include "content/shell/renderer/test_runner/mock_spell_check.h"
#include "base/logging.h"
#include "content/shell/renderer/test_runner/test_common.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "third_party/WebKit/public/platform/WebCString.h"
namespace content {
......@@ -56,7 +56,7 @@ bool MockSpellCheck::SpellCheckWord(const blink::WebString& text,
// If the given string doesn't include any ASCII characters, we can treat
// the string as valid one.
base::string16::iterator first_char =
std::find_if(string_text.begin(), string_text.end(), IsASCIIAlpha);
std::find_if(string_text.begin(), string_text.end(), isASCIIAlpha);
if (first_char == string_text.end())
return true;
int word_offset = std::distance(string_text.begin(), first_char);
......@@ -78,7 +78,7 @@ bool MockSpellCheck::SpellCheckWord(const blink::WebString& text,
if (word == misspelled_words_.at(i) &&
(static_cast<int>(string_text.length()) ==
word_offset + word_length ||
IsNotASCIIAlpha(string_text[word_offset + word_length]))) {
isNotASCIIAlpha(string_text[word_offset + word_length]))) {
*misspelled_offset = word_offset + skipped_length;
*misspelled_length = word_length;
break;
......@@ -89,7 +89,7 @@ bool MockSpellCheck::SpellCheckWord(const blink::WebString& text,
break;
base::string16::iterator last_char = std::find_if(
string_text.begin() + word_offset, string_text.end(), IsNotASCIIAlpha);
string_text.begin() + word_offset, string_text.end(), isNotASCIIAlpha);
if (last_char == string_text.end())
word_length = static_cast<int>(string_text.length()) - word_offset;
else
......
......@@ -8,6 +8,7 @@
#include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
#include "base/basictypes.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTask.h"
namespace blink {
......
......@@ -6,6 +6,7 @@
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_WEB_MIDI_ACCESSOR_H_
#include "base/basictypes.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTask.h"
#include "third_party/WebKit/public/platform/WebMIDIAccessor.h"
......
......@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTask.h"
#include "third_party/WebKit/public/web/WebSpeechRecognizer.h"
......
......@@ -6,6 +6,7 @@
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKWEBRTCDATACHANNELHANDLER_H_
#include "base/basictypes.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTask.h"
#include "third_party/WebKit/public/platform/WebRTCDataChannelHandler.h"
#include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h"
......
......@@ -6,6 +6,7 @@
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKWEBRTCDTMFSENDERHANDLER_H_
#include "base/basictypes.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTask.h"
#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
#include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandler.h"
......
......@@ -6,6 +6,7 @@
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCKWEBRTCPEERCONNECTIONHANDLER_H_
#include "base/basictypes.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTask.h"
#include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h"
#include "third_party/WebKit/public/platform/WebRTCSessionDescription.h"
......
// Copyright 2014 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 "content/shell/renderer/test_runner/test_common.h"
namespace content {
namespace {
const char layout_tests_pattern[] = "/LayoutTests/";
const std::string::size_type layout_tests_pattern_size =
sizeof(layout_tests_pattern) - 1;
const char file_url_pattern[] = "file:/";
const char file_test_prefix[] = "(file test):";
const char data_url_pattern[] = "data:";
const std::string::size_type data_url_pattern_size =
sizeof(data_url_pattern) - 1;
} // namespace
std::string NormalizeLayoutTestURL(const std::string& url) {
std::string result = url;
size_t pos;
if (!url.find(file_url_pattern) &&
((pos = url.find(layout_tests_pattern)) != std::string::npos)) {
// adjust file URLs to match upstream results.
result.replace(0, pos + layout_tests_pattern_size, file_test_prefix);
} else if (!url.find(data_url_pattern)) {
// URL-escape data URLs to match results upstream.
std::string path = url.substr(data_url_pattern_size);
result.replace(data_url_pattern_size, url.length(), path);
}
return result;
}
} // namespace content
......@@ -4,8 +4,8 @@
#include "content/shell/renderer/test_runner/web_permissions.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/WebTestDelegate.h"
#include "content/shell/renderer/test_runner/test_common.h"
#include "third_party/WebKit/public/platform/WebCString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
......@@ -22,8 +22,8 @@ bool WebPermissions::allowImage(bool enabled_per_settings,
bool allowed = enabled_per_settings && images_allowed_;
if (dump_callbacks_ && delegate_) {
delegate_->printMessage(std::string("PERMISSION CLIENT: allowImage(") +
NormalizeLayoutTestURL(image_url.spec()) + "): " +
(allowed ? "true" : "false") + "\n");
normalizeLayoutTestURL(image_url.spec()) + "): " +
(allowed ? "true" : "false") + "\n");
}
return allowed;
}
......@@ -32,8 +32,8 @@ bool WebPermissions::allowMedia(const blink::WebURL& image_url) {
bool allowed = media_allowed_;
if (dump_callbacks_ && delegate_)
delegate_->printMessage(std::string("PERMISSION CLIENT: allowMedia(") +
NormalizeLayoutTestURL(image_url.spec()) + "): " +
(allowed ? "true" : "false") + "\n");
normalizeLayoutTestURL(image_url.spec()) + "): " +
(allowed ? "true" : "false") + "\n");
return allowed;
}
......@@ -43,7 +43,7 @@ bool WebPermissions::allowScriptFromSource(bool enabled_per_settings,
if (dump_callbacks_ && delegate_) {
delegate_->printMessage(
std::string("PERMISSION CLIENT: allowScriptFromSource(") +
NormalizeLayoutTestURL(scriptURL.spec()) + "): " +
normalizeLayoutTestURL(scriptURL.spec()) + "): " +
(allowed ? "true" : "false") + "\n");
}
return allowed;
......
......@@ -10,6 +10,7 @@
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/TestInterfaces.h"
#include "content/shell/renderer/test_runner/TestPlugin.h"
#include "content/shell/renderer/test_runner/WebTestDelegate.h"
......
......@@ -16,7 +16,7 @@
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h"
#include "content/renderer/renderer_webkitplatformsupport_impl.h"
#include "content/shell/renderer/test_runner/test_common.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
#include "content/shell/renderer/test_runner/web_frame_test_proxy.h"
#include "content/shell/renderer/test_runner/web_test_proxy.h"
#include "third_party/WebKit/public/platform/WebBatteryStatus.h"
......@@ -253,7 +253,7 @@ std::string DumpHistoryItem(HistoryEntry::HistoryNode* node,
result.append(indent, ' ');
}
std::string url = NormalizeLayoutTestURL(item.urlString().utf8());
std::string url = normalizeLayoutTestURL(item.urlString().utf8());
result.append(url);
if (!item.target().isEmpty()) {
result.append(" (in frame \"");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment