summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrijubrata.bhaumik@intel.com <rijubrata.bhaumik@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-30 17:44:21 +0000
committerrijubrata.bhaumik@intel.com <rijubrata.bhaumik@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-30 17:44:21 +0000
commit2ad7e62b86892c8c09641bb61242ddf69268eb80 (patch)
treebdcddd2a585c2551946b982a8f5170ba435606d7
parent4a7442b5190f37f08b467e52dbafbdbcaf68dca3 (diff)
downloadchromium_src-2ad7e62b86892c8c09641bb61242ddf69268eb80.zip
chromium_src-2ad7e62b86892c8c09641bb61242ddf69268eb80.tar.gz
chromium_src-2ad7e62b86892c8c09641bb61242ddf69268eb80.tar.bz2
[DeviceLight] Add Layout support
Adds the necessary plumbing to make it possible to test the blink implementation of DeviceLight API using Layout Tests and TestRunner. This is part 3 of the Adding Device Light [content side] BUG=336424 Review URL: https://codereview.chromium.org/336823002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280626 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/public/test/layouttest_support.h4
-rw-r--r--content/shell/renderer/test_runner/WebTestDelegate.h7
-rw-r--r--content/shell/renderer/test_runner/test_runner.cc24
-rw-r--r--content/shell/renderer/test_runner/test_runner.h2
-rw-r--r--content/shell/renderer/webkit_test_runner.cc4
-rw-r--r--content/shell/renderer/webkit_test_runner.h1
-rw-r--r--content/test/layouttest_support.cc4
7 files changed, 45 insertions, 1 deletions
diff --git a/content/public/test/layouttest_support.h b/content/public/test/layouttest_support.h
index 7bb8e89..bf30db5 100644
--- a/content/public/test/layouttest_support.h
+++ b/content/public/test/layouttest_support.h
@@ -48,6 +48,10 @@ void EnableWebTestProxyCreation(
// Sets gamepad provider to be used for layout tests.
void SetMockGamepadProvider(RendererGamepadProvider* provider);
+// Sets a double that should be used when registering
+// a listener through WebKitPlatformSupport::setDeviceLightListener().
+void SetMockDeviceLightData(const double data);
+
// Sets WebDeviceMotionData that should be used when registering
// a listener through WebKitPlatformSupport::setDeviceMotionListener().
void SetMockDeviceMotionData(const blink::WebDeviceMotionData& data);
diff --git a/content/shell/renderer/test_runner/WebTestDelegate.h b/content/shell/renderer/test_runner/WebTestDelegate.h
index 8d9f004..09f37f7 100644
--- a/content/shell/renderer/test_runner/WebTestDelegate.h
+++ b/content/shell/renderer/test_runner/WebTestDelegate.h
@@ -29,6 +29,7 @@ struct WebURLError;
namespace content {
+class DeviceLightData;
class RendererGamepadProvider;
class WebTask;
class WebTestProxyBase;
@@ -44,7 +45,11 @@ public:
// Sets gamepad provider to be used for tests.
virtual void setGamepadProvider(RendererGamepadProvider*) = 0;
- // Set data to return when registering via Platform::setDeviceMotionListener().
+ // Set data to return when registering via
+ // Platform::setDeviceLightListener().
+ virtual void setDeviceLightData(const double) = 0;
+ // Set data to return when registering via
+ // Platform::setDeviceMotionListener().
virtual void setDeviceMotionData(const blink::WebDeviceMotionData&) = 0;
// Set data to return when registering via Platform::setDeviceOrientationListener().
virtual void setDeviceOrientationData(const blink::WebDeviceOrientationData&) = 0;
diff --git a/content/shell/renderer/test_runner/test_runner.cc b/content/shell/renderer/test_runner/test_runner.cc
index 3a50545..c0803a8 100644
--- a/content/shell/renderer/test_runner/test_runner.cc
+++ b/content/shell/renderer/test_runner/test_runner.cc
@@ -193,6 +193,8 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
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);
@@ -395,6 +397,8 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
&TestRunnerBindings::EnableAutoResizeMode)
.SetMethod("disableAutoResizeMode",
&TestRunnerBindings::DisableAutoResizeMode)
+ .SetMethod("setMockDeviceLight", &TestRunnerBindings::SetMockDeviceLight)
+ .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight)
.SetMethod("setMockDeviceMotion",
&TestRunnerBindings::SetMockDeviceMotion)
.SetMethod("setMockDeviceOrientation",
@@ -822,6 +826,17 @@ bool TestRunnerBindings::DisableAutoResizeMode(int new_width, int new_height) {
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;
@@ -1565,6 +1580,7 @@ void TestRunner::Reset() {
delegate_->deleteAllCookies();
delegate_->resetScreenOrientation();
ResetBatteryStatus();
+ ResetDeviceLight();
}
dump_editting_callbacks_ = false;
@@ -2270,6 +2286,14 @@ bool TestRunner::DisableAutoResizeMode(int new_width, int new_height) {
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,
diff --git a/content/shell/renderer/test_runner/test_runner.h b/content/shell/renderer/test_runner/test_runner.h
index b347904..55172f7 100644
--- a/content/shell/renderer/test_runner/test_runner.h
+++ b/content/shell/renderer/test_runner/test_runner.h
@@ -279,6 +279,8 @@ class TestRunner : public WebTestRunner,
int max_height);
bool DisableAutoResizeMode(int new_width, int new_height);
+ void SetMockDeviceLight(double value);
+ void ResetDeviceLight();
// Device Motion / Device Orientation related functions
void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x,
bool has_acceleration_y, double acceleration_y,
diff --git a/content/shell/renderer/webkit_test_runner.cc b/content/shell/renderer/webkit_test_runner.cc
index 8b20550..6ad298e 100644
--- a/content/shell/renderer/webkit_test_runner.cc
+++ b/content/shell/renderer/webkit_test_runner.cc
@@ -207,6 +207,10 @@ void WebKitTestRunner::setGamepadProvider(
SetMockGamepadProvider(provider);
}
+void WebKitTestRunner::setDeviceLightData(const double data) {
+ SetMockDeviceLightData(data);
+}
+
void WebKitTestRunner::setDeviceMotionData(const WebDeviceMotionData& data) {
SetMockDeviceMotionData(data);
}
diff --git a/content/shell/renderer/webkit_test_runner.h b/content/shell/renderer/webkit_test_runner.h
index 9cd1941..82e6d30 100644
--- a/content/shell/renderer/webkit_test_runner.h
+++ b/content/shell/renderer/webkit_test_runner.h
@@ -56,6 +56,7 @@ class WebKitTestRunner : public RenderViewObserver,
virtual void setEditCommand(const std::string& name,
const std::string& value) OVERRIDE;
virtual void setGamepadProvider(RendererGamepadProvider*) OVERRIDE;
+ virtual void setDeviceLightData(const double data) OVERRIDE;
virtual void setDeviceMotionData(
const blink::WebDeviceMotionData& data) OVERRIDE;
virtual void setDeviceOrientationData(
diff --git a/content/test/layouttest_support.cc b/content/test/layouttest_support.cc
index bbb57ad..09c15a3 100644
--- a/content/test/layouttest_support.cc
+++ b/content/test/layouttest_support.cc
@@ -86,6 +86,10 @@ void SetMockGamepadProvider(RendererGamepadProvider* provider) {
set_gamepad_provider(provider);
}
+void SetMockDeviceLightData(const double data) {
+ RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting(data);
+}
+
void SetMockDeviceMotionData(const WebDeviceMotionData& data) {
RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(data);
}