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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "ppapi/c/pp_var.h" | 9 #include "ppapi/c/pp_var.h" |
10 #include "ppapi/c/ppb_var.h" | 10 #include "ppapi/c/ppb_var.h" |
11 #include "ppapi/proxy/ppapi_proxy_test.h" | 11 #include "ppapi/proxy/ppapi_proxy_test.h" |
12 | 12 |
13 // TODO(dmichael): Make PPB_Var_Proxy and PluginResourceTracker thread-safe and | 13 // TODO(dmichael): Make PPB_Var_Proxy and PluginResourceTracker thread-safe and |
14 // add thread-safety tests here. | 14 // add thread-safety tests here. |
15 | 15 |
16 namespace { | 16 namespace { |
17 std::string VarToString(const PP_Var& var, const PPB_Var* ppb_var) { | 17 std::string VarToString(const PP_Var& var, const PPB_Var* ppb_var) { |
18 uint32_t len = 0; | 18 uint32_t len = 0; |
19 const char* utf8 = ppb_var->VarToUtf8(var, &len); | 19 const char* utf8 = ppb_var->VarToUtf8(var, &len); |
20 return std::string(utf8, len); | 20 return std::string(utf8, len); |
21 } | 21 } |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 namespace pp { | 24 namespace ppapi { |
25 namespace proxy { | 25 namespace proxy { |
26 | 26 |
27 class PPB_VarTest : public PluginProxyTest { | 27 class PPB_VarTest : public PluginProxyTest { |
28 public: | 28 public: |
29 PPB_VarTest() {} | 29 PPB_VarTest() {} |
30 }; | 30 }; |
31 | 31 |
32 TEST_F(PPB_VarTest, Strings) { | 32 TEST_F(PPB_VarTest, Strings) { |
33 const PPB_Var* ppb_var = static_cast<const PPB_Var*>( | 33 const PPB_Var* ppb_var = static_cast<const PPB_Var*>( |
34 plugin_dispatcher()->GetInterfaceFromDispatcher(PPB_VAR_INTERFACE)); | 34 plugin_dispatcher()->GetInterfaceFromDispatcher(PPB_VAR_INTERFACE)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 for (int i = 0; i < kNumStrings; ++i) { | 66 for (int i = 0; i < kNumStrings; ++i) { |
67 ppb_var->Release(vars[i]); | 67 ppb_var->Release(vars[i]); |
68 uint32_t len = 10; | 68 uint32_t len = 10; |
69 const char* utf8 = ppb_var->VarToUtf8(vars[i], &len); | 69 const char* utf8 = ppb_var->VarToUtf8(vars[i], &len); |
70 EXPECT_EQ(NULL, utf8); | 70 EXPECT_EQ(NULL, utf8); |
71 EXPECT_EQ(0u, len); | 71 EXPECT_EQ(0u, len); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 } // namespace proxy | 75 } // namespace proxy |
76 } // namespace pp | 76 } // namespace ppapi |
77 | 77 |
OLD | NEW |