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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
8 #include "content/public/test/render_view_test.h" | 8 #include "content/public/test/render_view_test.h" |
9 #include "content/public/common/file_chooser_params.h" | 9 #include "content/public/common/file_chooser_params.h" |
10 #include "content/renderer/pepper/mock_renderer_ppapi_host.h" | 10 #include "content/renderer/pepper/mock_renderer_ppapi_host.h" |
11 #include "content/renderer/pepper/pepper_file_chooser_host.h" | 11 #include "content/renderer/pepper/pepper_file_chooser_host.h" |
12 //#include "content/renderer/pepper/pepper_instance_state_accessor.h" | |
13 #include "content/renderer/render_view_impl.h" | 12 #include "content/renderer/render_view_impl.h" |
14 #include "content/test/test_content_client.h" | 13 #include "content/test/test_content_client.h" |
15 #include "ppapi/c/pp_errors.h" | 14 #include "ppapi/c/pp_errors.h" |
16 #include "ppapi/host/host_message_context.h" | 15 #include "ppapi/host/host_message_context.h" |
17 #include "ppapi/host/ppapi_host.h" | 16 #include "ppapi/host/ppapi_host.h" |
18 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
19 #include "ppapi/proxy/resource_message_params.h" | 18 #include "ppapi/proxy/resource_message_params.h" |
20 #include "ppapi/proxy/resource_message_test_sink.h" | 19 #include "ppapi/proxy/resource_message_test_sink.h" |
21 #include "ppapi/shared_impl/ppapi_permissions.h" | 20 #include "ppapi/shared_impl/ppapi_permissions.h" |
22 #include "ppapi/shared_impl/ppb_file_ref_shared.h" | 21 #include "ppapi/shared_impl/ppb_file_ref_shared.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 std::string FilePathToUTF8(const FilePath::StringType& path) { | 64 std::string FilePathToUTF8(const FilePath::StringType& path) { |
66 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
67 return UTF16ToUTF8(path); | 66 return UTF16ToUTF8(path); |
68 #else | 67 #else |
69 return path; | 68 return path; |
70 #endif | 69 #endif |
71 } | 70 } |
72 | 71 |
73 } // namespace | 72 } // namespace |
74 | 73 |
75 /* TODO(brettw) fix & re-enable this test. | |
76 TEST_F(PepperFileChooserHostTest, Show) { | 74 TEST_F(PepperFileChooserHostTest, Show) { |
77 PP_Resource pp_resource = 123; | 75 PP_Resource pp_resource = 123; |
78 | 76 |
79 MockRendererPpapiHost host(view_, pp_instance()); | 77 MockRendererPpapiHost host(view_, pp_instance()); |
80 PepperFileChooserHost chooser(&host, pp_instance(), pp_resource); | 78 PepperFileChooserHost chooser(&host, pp_instance(), pp_resource); |
81 | 79 |
| 80 // Say there's a user gesture. |
| 81 host.set_has_user_gesture(true); |
| 82 |
82 std::vector<std::string> accept; | 83 std::vector<std::string> accept; |
83 accept.push_back("text/plain"); | 84 accept.push_back("text/plain"); |
84 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); | 85 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); |
85 | 86 |
86 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); | 87 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); |
87 ppapi::host::HostMessageContext context(call_params); | 88 ppapi::host::HostMessageContext context(call_params); |
88 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); | 89 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); |
89 EXPECT_EQ(PP_OK_COMPLETIONPENDING, result); | 90 EXPECT_EQ(PP_OK_COMPLETIONPENDING, result); |
90 | 91 |
91 // The render view should have sent a chooser request to the browser | 92 // The render view should have sent a chooser request to the browser |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 ASSERT_TRUE(PpapiPluginMsg_FileChooser_ShowReply::Read(&reply_msg, | 128 ASSERT_TRUE(PpapiPluginMsg_FileChooser_ShowReply::Read(&reply_msg, |
128 &reply_msg_param)); | 129 &reply_msg_param)); |
129 const std::vector<ppapi::PPB_FileRef_CreateInfo>& chooser_results = | 130 const std::vector<ppapi::PPB_FileRef_CreateInfo>& chooser_results = |
130 reply_msg_param.a; | 131 reply_msg_param.a; |
131 ASSERT_EQ(1u, chooser_results.size()); | 132 ASSERT_EQ(1u, chooser_results.size()); |
132 // Note path is empty because this is an external filesystem. | 133 // Note path is empty because this is an external filesystem. |
133 EXPECT_EQ(std::string(), chooser_results[0].path); | 134 EXPECT_EQ(std::string(), chooser_results[0].path); |
134 EXPECT_EQ(FilePathToUTF8(selected_info.display_name), | 135 EXPECT_EQ(FilePathToUTF8(selected_info.display_name), |
135 chooser_results[0].name); | 136 chooser_results[0].name); |
136 } | 137 } |
137 */ | |
138 | 138 |
139 TEST_F(PepperFileChooserHostTest, NoUserGesture) { | 139 TEST_F(PepperFileChooserHostTest, NoUserGesture) { |
140 PP_Resource pp_resource = 123; | 140 PP_Resource pp_resource = 123; |
141 | 141 |
142 MockRendererPpapiHost host(view_, pp_instance()); | 142 MockRendererPpapiHost host(view_, pp_instance()); |
143 PepperFileChooserHost chooser(&host, pp_instance(), pp_resource); | 143 PepperFileChooserHost chooser(&host, pp_instance(), pp_resource); |
144 | 144 |
145 // Say there's no user gesture. | 145 // Say there's no user gesture. |
146 host.set_has_user_gesture(false); | 146 host.set_has_user_gesture(false); |
147 | 147 |
148 std::vector<std::string> accept; | 148 std::vector<std::string> accept; |
149 accept.push_back("text/plain"); | 149 accept.push_back("text/plain"); |
150 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); | 150 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); |
151 | 151 |
152 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); | 152 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); |
153 ppapi::host::HostMessageContext context(call_params); | 153 ppapi::host::HostMessageContext context(call_params); |
154 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); | 154 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); |
155 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); | 155 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); |
156 } | 156 } |
157 | 157 |
158 } // namespace content | 158 } // namespace content |
OLD | NEW |