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 #include <cstring> | 5 #include <cstring> |
6 | 6 |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
9 #include "ppapi/c/ppb_var.h" | 9 #include "ppapi/c/ppb_var.h" |
10 #include "ppapi/c/ppp_messaging.h" | 10 #include "ppapi/c/ppp_messaging.h" |
11 #include "ppapi/proxy/ppapi_proxy_test.h" | 11 #include "ppapi/proxy/ppapi_proxy_test.h" |
| 12 #include "ppapi/shared_impl/var.h" |
| 13 |
| 14 using ::ppapi::StringVar; |
12 | 15 |
13 namespace pp { | 16 namespace pp { |
14 namespace proxy { | 17 namespace proxy { |
15 | 18 |
16 namespace { | 19 namespace { |
17 | 20 |
18 // This is a poor man's mock of PPP_Messaging using global variables. Eventually | 21 // This is a poor man's mock of PPP_Messaging using global variables. Eventually |
19 // we should generalize making PPAPI interface mocks by using IDL or macro/ | 22 // we should generalize making PPAPI interface mocks by using IDL or macro/ |
20 // template magic. | 23 // template magic. |
21 PP_Instance received_instance; | 24 PP_Instance received_instance; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EXPECT_EQ(expected_var.type, received_var.type); | 122 EXPECT_EQ(expected_var.type, received_var.type); |
120 EXPECT_EQ(expected_var.value.as_double, received_var.value.as_double); | 123 EXPECT_EQ(expected_var.value.as_double, received_var.value.as_double); |
121 | 124 |
122 expected_var.type = PP_VARTYPE_STRING; | 125 expected_var.type = PP_VARTYPE_STRING; |
123 expected_var.value.as_id = 1979; | 126 expected_var.value.as_id = 1979; |
124 ResetReceived(); | 127 ResetReceived(); |
125 ppp_messaging->HandleMessage(expected_instance, expected_var); | 128 ppp_messaging->HandleMessage(expected_instance, expected_var); |
126 handle_message_called.Wait(); | 129 handle_message_called.Wait(); |
127 EXPECT_EQ(expected_instance, received_instance); | 130 EXPECT_EQ(expected_instance, received_instance); |
128 EXPECT_EQ(expected_var.type, received_var.type); | 131 EXPECT_EQ(expected_var.type, received_var.type); |
129 const std::string* received_string = | 132 |
130 plugin().var_tracker().GetExistingString(received_var); | 133 scoped_refptr<StringVar> received_string(StringVar::FromPPVar(received_var)); |
131 ASSERT_TRUE(received_string); | 134 ASSERT_TRUE(received_string.get()); |
132 EXPECT_EQ(kTestString, *received_string); | 135 EXPECT_EQ(kTestString, received_string->value()); |
133 // Now release the var, and the string should go away (because the ref | 136 // Now release the var, and the string should go away (because the ref |
134 // count should be one). | 137 // count should be one). |
135 plugin().var_tracker().Release(received_var); | 138 plugin().var_tracker().ReleaseVar(received_var); |
136 EXPECT_FALSE(plugin().var_tracker().GetExistingString(received_var)); | 139 EXPECT_FALSE(StringVar::FromPPVar(received_var).get()); |
137 } | 140 } |
138 | 141 |
139 } // namespace proxy | 142 } // namespace proxy |
140 } // namespace pp | 143 } // namespace pp |
141 | 144 |
OLD | NEW |