OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_TESTS_TEST_POST_MESSAGE_H_ | 5 #ifndef PPAPI_TESTS_TEST_POST_MESSAGE_H_ |
6 #define PPAPI_TESTS_TEST_POST_MESSAGE_H_ | 6 #define PPAPI_TESTS_TEST_POST_MESSAGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ppapi/c/dev/ppb_var_resource_dev.h" | |
12 #include "ppapi/c/ppb_file_system.h" | |
13 #include "ppapi/c/ppb_var.h" | |
11 #include "ppapi/tests/test_case.h" | 14 #include "ppapi/tests/test_case.h" |
12 | 15 |
13 class TestPostMessage : public TestCase { | 16 class TestPostMessage : public TestCase { |
14 public: | 17 public: |
15 explicit TestPostMessage(TestingInstance* instance); | 18 explicit TestPostMessage(TestingInstance* instance); |
16 virtual ~TestPostMessage(); | 19 virtual ~TestPostMessage(); |
17 | 20 |
18 private: | 21 private: |
19 // TestCase implementation. | 22 // TestCase implementation. |
20 virtual bool Init(); | 23 virtual bool Init(); |
(...skipping 10 matching lines...) Expand all Loading... | |
31 // 'message_event' - the message event parameter to the listener function. | 34 // 'message_event' - the message event parameter to the listener function. |
32 // This also adds the new listener to an array called 'eventListeners' on the | 35 // This also adds the new listener to an array called 'eventListeners' on the |
33 // plugin's DOM element. This is used by ClearListeners(). | 36 // plugin's DOM element. This is used by ClearListeners(). |
34 // Returns true on success, false on failure. | 37 // Returns true on success, false on failure. |
35 bool AddEchoingListener(const std::string& expression); | 38 bool AddEchoingListener(const std::string& expression); |
36 | 39 |
37 // Posts a message from JavaScript to the plugin. |func| should be a | 40 // Posts a message from JavaScript to the plugin. |func| should be a |
38 // JavaScript function which returns the variable to post. | 41 // JavaScript function which returns the variable to post. |
39 bool PostMessageFromJavaScript(const std::string& func); | 42 bool PostMessageFromJavaScript(const std::string& func); |
40 | 43 |
44 // Posts a message from JavaScript to the plugin. |func| should be a | |
45 // JavaScript function(callback) which calls |callback| with the variable to | |
46 // post. To wait for this message to be posted on the plugin side, use | |
47 // WaitForMessagesAsync, instead of WaitForMessages. | |
48 bool PostMessageFromJavaScriptAsync(const std::string& func); | |
49 | |
41 // Clear any listeners that have been added using AddEchoingListener by | 50 // Clear any listeners that have been added using AddEchoingListener by |
42 // calling removeEventListener for each. | 51 // calling removeEventListener for each. |
43 // Returns true on success, false on failure. | 52 // Returns true on success, false on failure. |
44 bool ClearListeners(); | 53 bool ClearListeners(); |
45 | 54 |
46 // Wait for pending messages; return the number of messages that were pending | 55 // Wait for pending messages; return the number of messages that were pending |
47 // at the time of invocation. | 56 // at the time of invocation. |
48 int WaitForMessages(); | 57 int WaitForMessages(); |
49 | 58 |
59 // Wait for pending messages sent by PostMessageFromJavaScriptAsync; return | |
60 // the number of messages that were pending at the time of invocation. | |
61 int WaitForMessagesAsync(); | |
62 | |
50 // Verifies that the given javascript assertions are true of the message | 63 // Verifies that the given javascript assertions are true of the message |
51 // (|test_data|) passed via PostMessage(). | 64 // (|test_data|) passed via PostMessage(). |
52 std::string CheckMessageProperties( | 65 std::string CheckMessageProperties( |
53 const pp::Var& test_data, | 66 const pp::Var& test_data, |
54 const std::vector<std::string>& properties_to_check); | 67 const std::vector<std::string>& properties_to_check); |
55 | 68 |
56 // Test that we can send a message from Instance::Init. Note the actual | 69 // 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 | 70 // message is sent in TestPostMessage::Init, and this test simply makes sure |
58 // we got it. | 71 // we got it. |
59 std::string TestSendInInit(); | 72 std::string TestSendInInit(); |
60 | 73 |
61 // Test some basic functionality; make sure we can send data successfully | 74 // Test some basic functionality; make sure we can send data successfully |
62 // in both directions. | 75 // in both directions. |
63 std::string TestSendingData(); | 76 std::string TestSendingData(); |
64 | 77 |
65 // Test sending ArrayBuffer vars in both directions. | 78 // Test sending ArrayBuffer vars in both directions. |
66 std::string TestSendingArrayBuffer(); | 79 std::string TestSendingArrayBuffer(); |
67 | 80 |
68 // Test sending Array vars in both directions. | 81 // Test sending Array vars in both directions. |
69 std::string TestSendingArray(); | 82 std::string TestSendingArray(); |
70 | 83 |
71 // Test sending Dictionary vars in both directions. | 84 // Test sending Dictionary vars in both directions. |
72 std::string TestSendingDictionary(); | 85 std::string TestSendingDictionary(); |
73 | 86 |
87 // Test sending Resource vars in both directions. | |
raymes
2013/10/22 05:59:21
nit: This comment is inaccurate. Currently we only
Matt Giuca
2013/10/23 08:05:54
Done.
| |
88 std::string TestSendingResource(); | |
89 | |
74 // Test sending a complex var with references and cycles in both directions. | 90 // Test sending a complex var with references and cycles in both directions. |
75 std::string TestSendingComplexVar(); | 91 std::string TestSendingComplexVar(); |
76 | 92 |
77 // Test the MessageEvent object that JavaScript received to make sure it is | 93 // Test the MessageEvent object that JavaScript received to make sure it is |
78 // of the right type and has all the expected fields. | 94 // of the right type and has all the expected fields. |
79 std::string TestMessageEvent(); | 95 std::string TestMessageEvent(); |
80 | 96 |
81 // Test sending a message when no handler exists, make sure nothing happens. | 97 // Test sending a message when no handler exists, make sure nothing happens. |
82 std::string TestNoHandler(); | 98 std::string TestNoHandler(); |
83 | 99 |
84 // Test sending from JavaScript to the plugin with extra parameters, make sure | 100 // Test sending from JavaScript to the plugin with extra parameters, make sure |
85 // nothing happens. | 101 // nothing happens. |
86 std::string TestExtraParam(); | 102 std::string TestExtraParam(); |
87 | 103 |
88 // Test sending messages off of the main thread. | 104 // Test sending messages off of the main thread. |
89 std::string TestNonMainThread(); | 105 std::string TestNonMainThread(); |
90 | 106 |
91 typedef std::vector<pp::Var> VarVector; | 107 typedef std::vector<pp::Var> VarVector; |
92 | 108 |
93 // This is used to store pp::Var objects we receive via a call to | 109 // This is used to store pp::Var objects we receive via a call to |
94 // HandleMessage. | 110 // HandleMessage. |
95 VarVector message_data_; | 111 VarVector message_data_; |
112 | |
113 // Interfaces for C APIs. | |
114 const PPB_Core* core_interface_; | |
115 const PPB_FileSystem* file_system_interface_; | |
116 const PPB_Var* var_interface_; | |
117 const PPB_VarResource_Dev* var_resource_interface_; | |
96 }; | 118 }; |
97 | 119 |
98 #endif // PPAPI_TESTS_TEST_POST_MESSAGE_H_ | 120 #endif // PPAPI_TESTS_TEST_POST_MESSAGE_H_ |
99 | 121 |
OLD | NEW |