summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/api
diff options
context:
space:
mode:
authorsammc <sammc@chromium.org>2014-09-24 22:48:48 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-25 05:49:07 +0000
commit10fd1075c2bbe78be3c0603ff2d9f3fa69646454 (patch)
tree690f420e7c1ced04f7bb1057a8b7f13e66a101e9 /extensions/renderer/api
parent86c176b0243c51bcc5d9049de35dc778cf491f91 (diff)
downloadchromium_src-10fd1075c2bbe78be3c0603ff2d9f3fa69646454.zip
chromium_src-10fd1075c2bbe78be3c0603ff2d9f3fa69646454.tar.gz
chromium_src-10fd1075c2bbe78be3c0603ff2d9f3fa69646454.tar.bz2
Add serialization support to the JS DataSender and DataReceiver.
To support persistent serial connections on mojo, serial.Connection and its dependencies must be serializable to mojo structs so it can be stashed. This adds serialization support to the two serial.Connection dependencies: DataSender and DataReceiver. BUG=389016 Review URL: https://codereview.chromium.org/571333002 Cr-Commit-Position: refs/heads/master@{#296658}
Diffstat (limited to 'extensions/renderer/api')
-rw-r--r--extensions/renderer/api/serial/data_receiver_unittest.cc33
-rw-r--r--extensions/renderer/api/serial/data_sender_unittest.cc30
-rw-r--r--extensions/renderer/api/serial/serial_api_unittest.cc2
3 files changed, 65 insertions, 0 deletions
diff --git a/extensions/renderer/api/serial/data_receiver_unittest.cc b/extensions/renderer/api/serial/data_receiver_unittest.cc
index f223cb3..567fdc4 100644
--- a/extensions/renderer/api/serial/data_receiver_unittest.cc
+++ b/extensions/renderer/api/serial/data_receiver_unittest.cc
@@ -22,6 +22,8 @@ class DataReceiverTest : public ApiTestBase {
env()->RegisterModule("data_receiver", IDR_DATA_RECEIVER_JS);
env()->RegisterModule("device/serial/data_stream.mojom",
IDR_DATA_STREAM_MOJOM_JS);
+ env()->RegisterModule("device/serial/data_stream_serialization.mojom",
+ IDR_DATA_STREAM_SERIALIZATION_MOJOM_JS);
service_provider()->AddService(base::Bind(
&DataReceiverTest::CreateDataSource, base::Unretained(this)));
}
@@ -103,6 +105,37 @@ TEST_F(DataReceiverTest, ReceiveErrorThenData) {
RunTest("data_receiver_unittest.js", "testReceiveErrorThenData");
}
+TEST_F(DataReceiverTest, ReceiveBeforeAndAfterSerialization) {
+ data_to_send_.push("a");
+ data_to_send_.push("b");
+ RunTest("data_receiver_unittest.js",
+ "testReceiveBeforeAndAfterSerialization");
+}
+
+TEST_F(DataReceiverTest, ReceiveErrorSerialization) {
+ error_to_send_.push(1);
+ error_to_send_.push(3);
+ RunTest("data_receiver_unittest.js", "testReceiveErrorSerialization");
+}
+
+TEST_F(DataReceiverTest, ReceiveDataAndErrorSerialization) {
+ data_to_send_.push("a");
+ data_to_send_.push("b");
+ error_to_send_.push(1);
+ error_to_send_.push(3);
+ RunTest("data_receiver_unittest.js", "testReceiveDataAndErrorSerialization");
+}
+
+TEST_F(DataReceiverTest, SerializeDuringReceive) {
+ data_to_send_.push("a");
+ RunTest("data_receiver_unittest.js", "testSerializeDuringReceive");
+}
+
+TEST_F(DataReceiverTest, SerializeAfterClose) {
+ data_to_send_.push("a");
+ RunTest("data_receiver_unittest.js", "testSerializeAfterClose");
+}
+
TEST_F(DataReceiverTest, SourceShutdown) {
error_to_send_.push(2);
RunTest("data_receiver_unittest.js", "testSourceShutdown");
diff --git a/extensions/renderer/api/serial/data_sender_unittest.cc b/extensions/renderer/api/serial/data_sender_unittest.cc
index 9f129e07..18a6236 100644
--- a/extensions/renderer/api/serial/data_sender_unittest.cc
+++ b/extensions/renderer/api/serial/data_sender_unittest.cc
@@ -22,6 +22,8 @@ class DataSenderTest : public ApiTestBase {
env()->RegisterModule("data_sender", IDR_DATA_SENDER_JS);
env()->RegisterModule("device/serial/data_stream.mojom",
IDR_DATA_STREAM_MOJOM_JS);
+ env()->RegisterModule("device/serial/data_stream_serialization.mojom",
+ IDR_DATA_STREAM_SERIALIZATION_MOJOM_JS);
service_provider()->AddService(
base::Bind(&DataSenderTest::CreateDataSink, base::Unretained(this)));
}
@@ -159,4 +161,32 @@ TEST_F(DataSenderTest, Close) {
RunTest("data_sender_unittest.js", "testClose");
}
+TEST_F(DataSenderTest, SendAfterSerialization) {
+ expected_data_.push("aa");
+ RunTest("data_sender_unittest.js", "testSendAfterSerialization");
+}
+
+TEST_F(DataSenderTest, SendErrorAfterSerialization) {
+ expected_data_.push("");
+ expected_data_.push("a");
+ error_to_report_.push(1);
+ RunTest("data_sender_unittest.js", "testSendErrorAfterSerialization");
+}
+
+TEST_F(DataSenderTest, CancelAfterSerialization) {
+ RunTest("data_sender_unittest.js", "testCancelAfterSerialization");
+}
+
+TEST_F(DataSenderTest, SerializeCancelsSendsInProgress) {
+ RunTest("data_sender_unittest.js", "testSerializeCancelsSendsInProgress");
+}
+
+TEST_F(DataSenderTest, SerializeWaitsForCancel) {
+ RunTest("data_sender_unittest.js", "testSerializeWaitsForCancel");
+}
+
+TEST_F(DataSenderTest, SerializeAfterClose) {
+ RunTest("data_sender_unittest.js", "testSerializeAfterClose");
+}
+
} // namespace extensions
diff --git a/extensions/renderer/api/serial/serial_api_unittest.cc b/extensions/renderer/api/serial/serial_api_unittest.cc
index e511d30..b4f8153 100644
--- a/extensions/renderer/api/serial/serial_api_unittest.cc
+++ b/extensions/renderer/api/serial/serial_api_unittest.cc
@@ -404,6 +404,8 @@ class SerialApiTest : public ApiTestBase {
env()->RegisterModule("serial_service", IDR_SERIAL_SERVICE_JS);
env()->RegisterModule("device/serial/data_stream.mojom",
IDR_DATA_STREAM_MOJOM_JS);
+ env()->RegisterModule("device/serial/data_stream_serialization.mojom",
+ IDR_DATA_STREAM_SERIALIZATION_MOJOM_JS);
env()->RegisterModule("device/serial/serial.mojom", IDR_SERIAL_MOJOM_JS);
service_provider()->AddService<device::serial::SerialService>(base::Bind(
&SerialApiTest::CreateSerialService, base::Unretained(this)));