Android: Remove unneeded Compositor::SetNeedsRedraw()
[chromium-blink-merge.git] / ppapi / tests / test_post_message.h
blob2f2f6287c087d4cab70a64505ddc4f1bb9964334
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PPAPI_TESTS_TEST_POST_MESSAGE_H_
6 #define PPAPI_TESTS_TEST_POST_MESSAGE_H_
8 #include <string>
9 #include <vector>
11 #include "ppapi/tests/test_case.h"
13 class TestPostMessage : public TestCase {
14 public:
15 explicit TestPostMessage(TestingInstance* instance);
16 virtual ~TestPostMessage();
18 private:
19 // TestCase implementation.
20 virtual bool Init();
21 virtual void RunTests(const std::string& filter);
23 // A handler for JS->Native calls to postMessage. Simply pushes
24 // the given value to the back of message_data_
25 virtual void HandleMessage(const pp::Var& message_data);
27 // Add a listener for message events which will echo back the given
28 // JavaScript expression by passing it to postMessage. JavaScript Variables
29 // available to the expression are:
30 // 'plugin' - the DOM element for the test plugin.
31 // 'message_event' - the message event parameter to the listener function.
32 // This also adds the new listener to an array called 'eventListeners' on the
33 // plugin's DOM element. This is used by ClearListeners().
34 // Returns true on success, false on failure.
35 bool AddEchoingListener(const std::string& expression);
37 // Posts a message from JavaScript to the plugin. |func| should be a
38 // JavaScript function which returns the variable to post.
39 bool PostMessageFromJavaScript(const std::string& func);
41 // Clear any listeners that have been added using AddEchoingListener by
42 // calling removeEventListener for each.
43 // Returns true on success, false on failure.
44 bool ClearListeners();
46 // Wait for pending messages; return the number of messages that were pending
47 // at the time of invocation.
48 int WaitForMessages();
50 // Verifies that the given javascript assertions are true of the message
51 // (|test_data|) passed via PostMessage().
52 std::string CheckMessageProperties(
53 const pp::Var& test_data,
54 const std::vector<std::string>& properties_to_check);
56 // Test that we can send a message from Instance::Init. Note the actual
57 // message is sent in TestPostMessage::Init, and this test simply makes sure
58 // we got it.
59 std::string TestSendInInit();
61 // Test some basic functionality; make sure we can send data successfully
62 // in both directions.
63 std::string TestSendingData();
65 // Test sending ArrayBuffer vars in both directions.
66 std::string TestSendingArrayBuffer();
68 // Test sending Array vars in both directions.
69 std::string TestSendingArray();
71 // Test sending Dictionary vars in both directions.
72 std::string TestSendingDictionary();
74 // Test sending a complex var with references and cycles in both directions.
75 std::string TestSendingComplexVar();
77 // Test the MessageEvent object that JavaScript received to make sure it is
78 // of the right type and has all the expected fields.
79 std::string TestMessageEvent();
81 // Test sending a message when no handler exists, make sure nothing happens.
82 std::string TestNoHandler();
84 // Test sending from JavaScript to the plugin with extra parameters, make sure
85 // nothing happens.
86 std::string TestExtraParam();
88 // Test sending messages off of the main thread.
89 std::string TestNonMainThread();
91 typedef std::vector<pp::Var> VarVector;
93 // This is used to store pp::Var objects we receive via a call to
94 // HandleMessage.
95 VarVector message_data_;
98 #endif // PPAPI_TESTS_TEST_POST_MESSAGE_H_