Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: ppapi/tests/test_post_message.h

Issue 6538028: A proposal for an initial postMessage interface. This will allow JavaScript ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/tests/test_post_message.h
===================================================================
--- ppapi/tests/test_post_message.h (revision 0)
+++ ppapi/tests/test_post_message.h (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
polina 2011/03/17 02:59:28 2011
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_TESTS_TEST_POST_MESSAGE_H_
+#define PPAPI_TESTS_TEST_POST_MESSAGE_H_
+
+#include <string>
+#include <vector>
+
+#include "ppapi/tests/test_case.h"
+
+struct PPB_Testing_Dev;
+
+class TestPostMessage : public TestCase {
+ public:
+ explicit TestPostMessage(TestingInstance* instance)
+ : TestCase(instance), testing_interface_(NULL) {}
+
+ private:
+ // TestCase implementation.
+ virtual bool Init();
+ virtual void RunTest();
+
+ // A handler for JS->Native calls to postMessage. Simply pushes
+ // the given value to the back of message_data_
+ virtual void HandleMessage(const pp::Var& message_data);
+
+ // Set the JavaScript onmessage handler to echo back some expression based on
+ // the message_event by passing it to postMessage. Returns true on success,
+ // false on failure.
+ bool MakeOnMessageEcho(const std::string& expression);
+
+ // Test some basic functionality; make sure we can send data successfully
+ // in both directions.
+ std::string TestSendingData();
+
+ // Test the MessageEvent object that JavaScript received to make sure it is
+ // of the right type and has all the expected fields.
+ std::string TestMessageEvent();
+
+ // Test sending a message when no handler exists, make sure nothing happens.
+ std::string TestNoHandler();
+
+ const PPB_Testing_Dev* testing_interface_;
+
+ // This is used to store pp::Var objects we receive via a call to
+ // HandleMessage.
+ std::vector<pp::Var> message_data_;
+};
+
+#endif // PPAPI_TESTS_TEST_POST_MESSAGE_H_
+
Property changes on: ppapi/tests/test_post_message.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698