#include "base/logging.h"
#include "content/shell/common/test_runner/test_preferences.h"
-#include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h"
-#include "content/shell/renderer/test_runner/TestInterfaces.h"
#include "content/shell/renderer/test_runner/WebTestDelegate.h"
#include "content/shell/renderer/test_runner/mock_web_push_client.h"
+#include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h"
#include "content/shell/renderer/test_runner/notification_presenter.h"
+#include "content/shell/renderer/test_runner/test_interfaces.h"
#include "content/shell/renderer/test_runner/web_permissions.h"
#include "content/shell/renderer/test_runner/web_test_proxy.h"
#include "gin/arguments.h"
int max_width,
int max_height);
bool DisableAutoResizeMode(int new_width, int new_height);
+ void SetMockDeviceLight(double value);
+ void ResetDeviceLight();
void SetMockDeviceMotion(gin::Arguments* args);
void SetMockDeviceOrientation(gin::Arguments* args);
void SetMockScreenOrientation(const std::string& orientation);
void DumpBackForwardList();
void DumpSelectionRect();
void SetPrinting();
+ void ClearPrinting();
void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value);
void SetWillSendRequestClearHeader(const std::string& header);
void DumpResourceRequestPriorities();
void SetMIDIAccessorResult(bool result);
void SetMIDISysexPermission(bool value);
void GrantWebNotificationPermission(gin::Arguments* args);
+ void ClearWebNotificationPermissions();
bool SimulateWebNotificationClick(const std::string& value);
void AddMockSpeechRecognitionResult(const std::string& transcript,
double confidence);
void DisplayAsync();
void DisplayAsyncThen(v8::Handle<v8::Function> callback);
void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback);
+ void CopyImageAtAndCapturePixelsAsyncThen(int x,
+ int y,
+ v8::Handle<v8::Function> callback);
void SetCustomTextOutput(std::string output);
void SetViewSourceForFrame(const std::string& name, bool enabled);
- void setMockPushClientSuccess(const std::string& end_point,
+ void SetMockPushClientSuccess(const std::string& endpoint,
const std::string& registration_id);
- void setMockPushClientError(const std::string& message);
+ void SetMockPushClientError(const std::string& message);
bool GlobalFlag();
void SetGlobalFlag(bool value);
&TestRunnerBindings::EnableAutoResizeMode)
.SetMethod("disableAutoResizeMode",
&TestRunnerBindings::DisableAutoResizeMode)
+ .SetMethod("setMockDeviceLight", &TestRunnerBindings::SetMockDeviceLight)
+ .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight)
.SetMethod("setMockDeviceMotion",
&TestRunnerBindings::SetMockDeviceMotion)
.SetMethod("setMockDeviceOrientation",
&TestRunnerBindings::SetMockScreenOrientation)
.SetMethod("didChangeBatteryStatus",
&TestRunnerBindings::DidChangeBatteryStatus)
- .SetMethod("resetBatteryStatus",
- &TestRunnerBindings::ResetBatteryStatus)
+ .SetMethod("resetBatteryStatus", &TestRunnerBindings::ResetBatteryStatus)
.SetMethod("didAcquirePointerLock",
&TestRunnerBindings::DidAcquirePointerLock)
.SetMethod("didNotAcquirePointerLock",
&TestRunnerBindings::DumpBackForwardList)
.SetMethod("dumpSelectionRect", &TestRunnerBindings::DumpSelectionRect)
.SetMethod("setPrinting", &TestRunnerBindings::SetPrinting)
+ .SetMethod("clearPrinting", &TestRunnerBindings::ClearPrinting)
.SetMethod(
"setShouldStayOnPageAfterHandlingBeforeUnload",
&TestRunnerBindings::SetShouldStayOnPageAfterHandlingBeforeUnload)
&TestRunnerBindings::PathToLocalResource)
.SetMethod("setBackingScaleFactor",
&TestRunnerBindings::SetBackingScaleFactor)
- .SetMethod("setColorProfile",
- &TestRunnerBindings::SetColorProfile)
+ .SetMethod("setColorProfile", &TestRunnerBindings::SetColorProfile)
.SetMethod("setPOSIXLocale", &TestRunnerBindings::SetPOSIXLocale)
.SetMethod("setMIDIAccessorResult",
&TestRunnerBindings::SetMIDIAccessorResult)
&TestRunnerBindings::SetMIDISysexPermission)
.SetMethod("grantWebNotificationPermission",
&TestRunnerBindings::GrantWebNotificationPermission)
+ .SetMethod("clearWebNotificationPermissions",
+ &TestRunnerBindings::ClearWebNotificationPermissions)
.SetMethod("simulateWebNotificationClick",
&TestRunnerBindings::SimulateWebNotificationClick)
.SetMethod("addMockSpeechRecognitionResult",
&TestRunnerBindings::RemoveWebPageOverlay)
.SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync)
.SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen)
- .SetMethod("capturePixelsAsyncThen", &TestRunnerBindings::CapturePixelsAsyncThen)
+ .SetMethod("capturePixelsAsyncThen",
+ &TestRunnerBindings::CapturePixelsAsyncThen)
+ .SetMethod("copyImageAtAndCapturePixelsAsyncThen",
+ &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen)
.SetMethod("setCustomTextOutput",
&TestRunnerBindings::SetCustomTextOutput)
.SetMethod("setViewSourceForFrame",
&TestRunnerBindings::SetViewSourceForFrame)
.SetMethod("setMockPushClientSuccess",
- &TestRunnerBindings::setMockPushClientSuccess)
+ &TestRunnerBindings::SetMockPushClientSuccess)
.SetMethod("setMockPushClientError",
- &TestRunnerBindings::setMockPushClientError)
+ &TestRunnerBindings::SetMockPushClientError)
// Properties.
.SetProperty("globalFlag",
return false;
}
+void TestRunnerBindings::SetMockDeviceLight(double value) {
+ if (!runner_)
+ return;
+ runner_->SetMockDeviceLight(value);
+}
+
+void TestRunnerBindings::ResetDeviceLight() {
+ if (runner_)
+ runner_->ResetDeviceLight();
+}
+
void TestRunnerBindings::SetMockDeviceMotion(gin::Arguments* args) {
if (!runner_)
return;
runner_->SetPrinting();
}
+void TestRunnerBindings::ClearPrinting() {
+ if (runner_)
+ runner_->ClearPrinting();
+}
+
void TestRunnerBindings::SetShouldStayOnPageAfterHandlingBeforeUnload(
bool value) {
if (runner_)
bool permission_granted = true;
args->GetNext(&origin);
args->GetNext(&permission_granted);
- return runner_->GrantWebNotificationPermission(origin, permission_granted);
+ return runner_->GrantWebNotificationPermission(GURL(origin),
+ permission_granted);
}
}
+void TestRunnerBindings::ClearWebNotificationPermissions() {
+ if (runner_)
+ runner_->ClearWebNotificationPermissions();
+}
+
bool TestRunnerBindings::SimulateWebNotificationClick(
const std::string& value) {
if (runner_)
runner_->CapturePixelsAsyncThen(callback);
}
+void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen(
+ int x, int y, v8::Handle<v8::Function> callback) {
+ if (runner_)
+ runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback);
+}
+
void TestRunnerBindings::SetCustomTextOutput(std::string output) {
runner_->setCustomTextOutput(output);
}
}
}
-void TestRunnerBindings::setMockPushClientSuccess(
- const std::string& end_point, const std::string& registration_id) {
+void TestRunnerBindings::SetMockPushClientSuccess(
+ const std::string& endpoint,
+ const std::string& registration_id) {
if (!runner_)
return;
- runner_->SetMockPushClientSuccess(end_point, registration_id);
+ runner_->SetMockPushClientSuccess(endpoint, registration_id);
}
-void TestRunnerBindings::setMockPushClientError(const std::string& message) {
+void TestRunnerBindings::SetMockPushClientError(const std::string& message) {
if (!runner_)
return;
runner_->SetMockPushClientError(message);
delegate_->deleteAllCookies();
delegate_->resetScreenOrientation();
ResetBatteryStatus();
+ ResetDeviceLight();
}
dump_editting_callbacks_ = false;
}
int TestRunner::WindowCount() {
- return test_interfaces_->windowList().size();
+ return test_interfaces_->GetWindowList().size();
}
void TestRunner::SetCloseRemainingWindowsWhenComplete(
}
void TestRunner::ResetTestHelperControllers() {
- test_interfaces_->resetTestHelperControllers();
+ test_interfaces_->ResetTestHelperControllers();
}
void TestRunner::SetTabKeyCyclesThroughElements(
return true;
}
+void TestRunner::SetMockDeviceLight(double value) {
+ delegate_->setDeviceLightData(value);
+}
+
+void TestRunner::ResetDeviceLight() {
+ delegate_->setDeviceLightData(-1);
+}
+
void TestRunner::SetMockDeviceMotion(
bool has_acceleration_x, double acceleration_x,
bool has_acceleration_y, double acceleration_y,
is_printing_ = true;
}
+void TestRunner::ClearPrinting() {
+ is_printing_ = false;
+}
+
void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) {
should_stay_on_page_after_handling_before_unload_ = value;
}
void TestRunner::SetMIDISysexPermission(bool value) {
const std::vector<WebTestProxyBase*>& windowList =
- test_interfaces_->windowList();
+ test_interfaces_->GetWindowList();
for (unsigned i = 0; i < windowList.size(); ++i)
windowList.at(i)->GetMIDIClientMock()->setSysexPermission(value);
}
-void TestRunner::GrantWebNotificationPermission(const std::string& origin,
+void TestRunner::GrantWebNotificationPermission(const GURL& origin,
bool permission_granted) {
- notification_presenter_->GrantPermission(origin, permission_granted);
+ delegate_->grantWebNotificationPermission(origin, permission_granted);
+}
+
+void TestRunner::ClearWebNotificationPermissions() {
+ delegate_->clearWebNotificationPermissions();
}
bool TestRunner::SimulateWebNotificationClick(const std::string& value) {
void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript,
double confidence) {
- proxy_->GetSpeechRecognizerMock()->addMockResult(
+ proxy_->GetSpeechRecognizerMock()->AddMockResult(
WebString::fromUTF8(transcript), confidence);
}
void TestRunner::SetMockSpeechRecognitionError(const std::string& error,
const std::string& message) {
- proxy_->GetSpeechRecognizerMock()->setError(WebString::fromUTF8(error),
- WebString::fromUTF8(message));
+ proxy_->GetSpeechRecognizerMock()->SetError(WebString::fromUTF8(error),
+ WebString::fromUTF8(message));
}
bool TestRunner::WasMockSpeechRecognitionAborted() {
- return proxy_->GetSpeechRecognizerMock()->wasAborted();
+ return proxy_->GetSpeechRecognizerMock()->WasAborted();
}
void TestRunner::AddWebPageOverlay() {
base::Passed(&task)));
}
+void TestRunner::CopyImageAtAndCapturePixelsAsyncThen(
+ int x, int y, v8::Handle<v8::Function> callback) {
+ scoped_ptr<InvokeCallbackTask> task(
+ new InvokeCallbackTask(this, callback));
+ proxy_->CopyImageAtAndCapturePixels(
+ x, y, base::Bind(&TestRunner::CapturePixelsCallback,
+ base::Unretained(this),
+ base::Passed(&task)));
+}
+
void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task,
const SkBitmap& snapshot) {
v8::Isolate* isolate = blink::mainThreadIsolate();
v8::Handle<v8::Value> argv[3];
SkAutoLockPixels snapshot_lock(snapshot);
+ // Size can be 0 for cases where copyImageAt was called on position
+ // that doesn't have an image.
int width = snapshot.info().fWidth;
- DCHECK_NE(0, width);
argv[0] = v8::Number::New(isolate, width);
int height = snapshot.info().fHeight;
- DCHECK_NE(0, height);
argv[1] = v8::Number::New(isolate, height);
blink::WebArrayBuffer buffer =
blink::WebArrayBuffer::create(snapshot.getSize(), 1);
memcpy(buffer.data(), snapshot.getPixels(), buffer.byteLength());
+#if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT
+ {
+ // Skia's internal byte order is BGRA. Must swap the B and R channels in
+ // order to provide a consistent ordering to the layout tests.
+ unsigned char* pixels = static_cast<unsigned char*>(buffer.data());
+ unsigned len = buffer.byteLength();
+ for (unsigned i = 0; i < len; i += 4) {
+ std::swap(pixels[i], pixels[i + 2]);
+ }
+ }
+#endif
+
argv[2] = blink::WebArrayBufferConverter::toV8Value(
&buffer, context->Global(), isolate);
InvokeCallback(task.Pass());
}
-void TestRunner::SetMockPushClientSuccess(
- const std::string& end_point, const std::string& registration_id) {
- proxy_->GetPushClientMock()->SetMockSuccessValues(end_point, registration_id);
+void TestRunner::SetMockPushClientSuccess(const std::string& endpoint,
+ const std::string& registration_id) {
+ proxy_->GetPushClientMock()->SetMockSuccessValues(endpoint, registration_id);
}
void TestRunner::SetMockPushClientError(const std::string& message) {