OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ppapi/c/dev/ppb_memory_dev.h" | 8 #include "ppapi/c/dev/ppb_memory_dev.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/ppb_image_data.h" | 10 #include "ppapi/c/ppb_image_data.h" |
11 #include "ppapi/proxy/pdf_resource.h" | 11 #include "ppapi/proxy/pdf_resource.h" |
12 #include "ppapi/proxy/ppapi_messages.h" | 12 #include "ppapi/proxy/ppapi_messages.h" |
13 #include "ppapi/proxy/ppapi_proxy_test.h" | 13 #include "ppapi/proxy/ppapi_proxy_test.h" |
14 #include "ppapi/proxy/ppb_image_data_proxy.h" | 14 #include "ppapi/proxy/ppb_image_data_proxy.h" |
15 #include "ppapi/proxy/serialized_handle.h" | 15 #include "ppapi/proxy/serialized_handle.h" |
16 #include "ppapi/shared_impl/proxy_lock.h" | 16 #include "ppapi/shared_impl/proxy_lock.h" |
17 #include "ppapi/shared_impl/scoped_pp_var.h" | 17 #include "ppapi/shared_impl/scoped_pp_var.h" |
18 #include "ppapi/shared_impl/var.h" | 18 #include "ppapi/shared_impl/var.h" |
19 #include "ppapi/thunk/thunk.h" | 19 #include "ppapi/thunk/thunk.h" |
20 | 20 |
21 namespace ppapi { | 21 namespace ppapi { |
22 namespace proxy { | 22 namespace proxy { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 typedef PluginProxyTest PDFResourceTest; | 26 typedef PluginProxyTest PDFResourceTest; |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 TEST_F(PDFResourceTest, GetLocalizedString) { | |
31 const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk(); | |
32 | |
33 std::string expected_string = "hello"; | |
34 PpapiPluginMsg_PDF_GetLocalizedStringReply reply_msg(expected_string); | |
35 ResourceSyncCallHandler handler( | |
36 &sink(), | |
37 PpapiHostMsg_PDF_GetLocalizedString::ID, | |
38 PP_OK, | |
39 reply_msg); | |
40 sink().AddFilter(&handler); | |
41 | |
42 PP_Var var = pdf_iface->GetLocalizedString( | |
43 pp_instance(), PP_RESOURCESTRING_PDFGETPASSWORD); | |
44 | |
45 { | |
46 ProxyAutoLock lock; | |
47 ScopedPPVar release_var(ScopedPPVar::PassRef(), var); | |
48 StringVar* string_var = StringVar::FromPPVar(var); | |
49 ASSERT_TRUE(string_var != NULL); | |
50 std::string actual_string = string_var->value(); | |
51 | |
52 ASSERT_EQ(PpapiHostMsg_PDF_GetLocalizedString::ID, | |
53 handler.last_handled_msg().type()); | |
54 ASSERT_EQ(expected_string, actual_string); | |
55 } | |
56 | |
57 // Remove the filter or it will be destroyed before the sink() is destroyed. | |
58 sink().RemoveFilter(&handler); | |
59 } | |
60 | |
61 TEST_F(PDFResourceTest, SearchString) { | 30 TEST_F(PDFResourceTest, SearchString) { |
62 ProxyAutoLock lock; | 31 ProxyAutoLock lock; |
63 // Instantiate a resource explicitly so we can specify the locale. | 32 // Instantiate a resource explicitly so we can specify the locale. |
64 scoped_refptr<PDFResource> pdf_resource( | 33 scoped_refptr<PDFResource> pdf_resource( |
65 new PDFResource(Connection(&sink(), &sink()), pp_instance())); | 34 new PDFResource(Connection(&sink(), &sink()), pp_instance())); |
66 pdf_resource->SetLocaleForTest("en-US"); | 35 pdf_resource->SetLocaleForTest("en-US"); |
67 | 36 |
68 base::string16 input; | 37 base::string16 input; |
69 base::string16 term; | 38 base::string16 term; |
70 base::UTF8ToUTF16("abcdefabcdef", 12, &input); | 39 base::UTF8ToUTF16("abcdefabcdef", 12, &input); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 pdf_iface->SaveAs(pp_instance()); | 120 pdf_iface->SaveAs(pp_instance()); |
152 | 121 |
153 ResourceMessageCallParams params; | 122 ResourceMessageCallParams params; |
154 IPC::Message msg; | 123 IPC::Message msg; |
155 ASSERT_TRUE(sink().GetFirstResourceCallMatching( | 124 ASSERT_TRUE(sink().GetFirstResourceCallMatching( |
156 PpapiHostMsg_PDF_SaveAs::ID, ¶ms, &msg)); | 125 PpapiHostMsg_PDF_SaveAs::ID, ¶ms, &msg)); |
157 } | 126 } |
158 | 127 |
159 } // namespace proxy | 128 } // namespace proxy |
160 } // namespace ppapi | 129 } // namespace ppapi |
OLD | NEW |