Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Side by Side Diff: trunk/src/ppapi/proxy/file_chooser_resource_unittest.cc

Issue 12920003: Revert 189518 "PPAPI: Remove threading options; it's always on" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "ppapi/c/dev/ppb_file_chooser_dev.h" 6 #include "ppapi/c/dev/ppb_file_chooser_dev.h"
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/proxy/file_chooser_resource.h" 8 #include "ppapi/proxy/file_chooser_resource.h"
9 #include "ppapi/proxy/locking_resource_releaser.h"
10 #include "ppapi/proxy/ppapi_messages.h" 9 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/proxy/ppapi_proxy_test.h" 10 #include "ppapi/proxy/ppapi_proxy_test.h"
12 #include "ppapi/shared_impl/proxy_lock.h" 11 #include "ppapi/shared_impl/proxy_lock.h"
12 #include "ppapi/shared_impl/scoped_pp_resource.h"
13 #include "ppapi/shared_impl/scoped_pp_var.h" 13 #include "ppapi/shared_impl/scoped_pp_var.h"
14 #include "ppapi/shared_impl/var.h" 14 #include "ppapi/shared_impl/var.h"
15 #include "ppapi/thunk/thunk.h" 15 #include "ppapi/thunk/thunk.h"
16 16
17 namespace ppapi { 17 namespace ppapi {
18 namespace proxy { 18 namespace proxy {
19 19
20 namespace { 20 namespace {
21 21
22 typedef PluginProxyTest FileChooserResourceTest; 22 typedef PluginProxyTest FileChooserResourceTest;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return output.size() == kCount; 60 return output.size() == kCount;
61 } 61 }
62 62
63 } // namespace 63 } // namespace
64 64
65 // Does a full test of Show() and reply functionality in the plugin side using 65 // Does a full test of Show() and reply functionality in the plugin side using
66 // the public C interfaces. 66 // the public C interfaces.
67 TEST_F(FileChooserResourceTest, Show) { 67 TEST_F(FileChooserResourceTest, Show) {
68 const PPB_FileChooser_Dev_0_6* chooser_iface = 68 const PPB_FileChooser_Dev_0_6* chooser_iface =
69 thunk::GetPPB_FileChooser_Dev_0_6_Thunk(); 69 thunk::GetPPB_FileChooser_Dev_0_6_Thunk();
70 LockingResourceReleaser res( 70 ScopedPPResource res(ScopedPPResource::PassRef(),
71 chooser_iface->Create(pp_instance(), PP_FILECHOOSERMODE_OPEN, 71 chooser_iface->Create(pp_instance(), PP_FILECHOOSERMODE_OPEN,
72 PP_MakeUndefined())); 72 PP_MakeUndefined()));
73 73
74 std::vector<PP_Resource> dest; 74 std::vector<PP_Resource> dest;
75 PP_ArrayOutput output; 75 PP_ArrayOutput output;
76 output.GetDataBuffer = &GetFileRefDataBuffer; 76 output.GetDataBuffer = &GetFileRefDataBuffer;
77 output.user_data = &dest; 77 output.user_data = &dest;
78 78
79 int32_t result = chooser_iface->Show( 79 int32_t result = chooser_iface->Show(
80 res.get(), output, PP_MakeCompletionCallback(&DoNothingCallback, NULL)); 80 res, output, PP_MakeCompletionCallback(&DoNothingCallback, NULL));
81 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 81 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
82 82
83 // Should have sent a "show" message. 83 // Should have sent a "show" message.
84 ResourceMessageCallParams params; 84 ResourceMessageCallParams params;
85 IPC::Message msg; 85 IPC::Message msg;
86 ASSERT_TRUE(sink().GetFirstResourceCallMatching( 86 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
87 PpapiHostMsg_FileChooser_Show::ID, &params, &msg)); 87 PpapiHostMsg_FileChooser_Show::ID, &params, &msg));
88 88
89 ResourceMessageReplyParams reply_params(params.pp_resource(), 89 ResourceMessageReplyParams reply_params(params.pp_resource(),
90 params.sequence()); 90 params.sequence());
91 reply_params.set_result(PP_OK); 91 reply_params.set_result(PP_OK);
92 92
93 // Synthesize a response with one file ref in it. Note that it must have a 93 // Synthesize a response with one file ref in it. Note that it must have a
94 // host resource value set or deserialization will fail. Since there isn't 94 // host resource value set or deserialization will fail. Since there isn't
95 // actually a host, this can be whatever we want. 95 // actually a host, this can be whatever we want.
96 std::vector<PPB_FileRef_CreateInfo> create_info_array; 96 std::vector<PPB_FileRef_CreateInfo> create_info_array;
97 PPB_FileRef_CreateInfo create_info; 97 PPB_FileRef_CreateInfo create_info;
98 create_info.resource.SetHostResource(pp_instance(), 123); 98 create_info.resource.SetHostResource(pp_instance(), 123);
99 create_info.path = "foo/bar"; 99 create_info.path = "foo/bar";
100 create_info.name = "baz"; 100 create_info.name = "baz";
101 create_info_array.push_back(create_info); 101 create_info_array.push_back(create_info);
102 ASSERT_TRUE(plugin_dispatcher()->OnMessageReceived( 102 ASSERT_TRUE(plugin_dispatcher()->OnMessageReceived(
103 PpapiPluginMsg_ResourceReply(reply_params, 103 PpapiPluginMsg_ResourceReply(reply_params,
104 PpapiPluginMsg_FileChooser_ShowReply(create_info_array)))); 104 PpapiPluginMsg_FileChooser_ShowReply(create_info_array))));
105 105
106 // Should have populated our vector. 106 // Should have populated our vector.
107 ASSERT_EQ(1u, dest.size()); 107 ASSERT_EQ(1u, dest.size());
108 LockingResourceReleaser dest_deletor(dest[0]); // Ensure it's cleaned up. 108 ScopedPPResource dest_deletor(dest[0]); // Ensure it's cleaned up.
109 109
110 const PPB_FileRef_1_0* file_ref_iface = thunk::GetPPB_FileRef_1_0_Thunk(); 110 const PPB_FileRef_1_0* file_ref_iface = thunk::GetPPB_FileRef_1_0_Thunk();
111 EXPECT_EQ(PP_FILESYSTEMTYPE_EXTERNAL, 111 EXPECT_EQ(PP_FILESYSTEMTYPE_EXTERNAL,
112 file_ref_iface->GetFileSystemType(dest[0])); 112 file_ref_iface->GetFileSystemType(dest[0]));
113 113
114 PP_Var name_var(file_ref_iface->GetName(dest[0])); 114 PP_Var name_var(file_ref_iface->GetName(dest[0]));
115 { 115 {
116 ProxyAutoLock lock; 116 ProxyAutoLock lock;
117 ScopedPPVar release_name_var(ScopedPPVar::PassRef(), name_var); 117 ScopedPPVar release_name_var(ScopedPPVar::PassRef(), name_var);
118 EXPECT_VAR_IS_STRING(create_info.name, name_var); 118 EXPECT_VAR_IS_STRING(create_info.name, name_var);
(...skipping 18 matching lines...) Expand all
137 EXPECT_TRUE(CheckParseAcceptType(" app/txt , app/pdf ", 137 EXPECT_TRUE(CheckParseAcceptType(" app/txt , app/pdf ",
138 "app/txt", "app/pdf")); 138 "app/txt", "app/pdf"));
139 139
140 // No dot or slash ones should be skipped. 140 // No dot or slash ones should be skipped.
141 EXPECT_TRUE(CheckParseAcceptType("foo", NULL, NULL)); 141 EXPECT_TRUE(CheckParseAcceptType("foo", NULL, NULL));
142 EXPECT_TRUE(CheckParseAcceptType("foo,.txt", ".txt", NULL)); 142 EXPECT_TRUE(CheckParseAcceptType("foo,.txt", ".txt", NULL));
143 } 143 }
144 144
145 } // namespace proxy 145 } // namespace proxy
146 } // namespace ppapi 146 } // namespace ppapi
OLDNEW
« no previous file with comments | « trunk/src/ppapi/proxy/device_enumeration_resource_helper_unittest.cc ('k') | trunk/src/ppapi/proxy/flash_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698