| 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
| 8 #include "content/public/common/file_chooser_params.h" | 8 #include "content/public/common/file_chooser_params.h" |
| 9 #include "content/public/test/render_view_test.h" | 9 #include "content/public/test/render_view_test.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/render_view_impl.h" | 12 #include "content/renderer/render_view_impl.h" |
| 13 #include "content/test/test_content_client.h" | 13 #include "content/test/test_content_client.h" |
| 14 #include "ppapi/c/pp_errors.h" | 14 #include "ppapi/c/pp_errors.h" |
| 15 #include "ppapi/host/host_message_context.h" | 15 #include "ppapi/host/host_message_context.h" |
| 16 #include "ppapi/host/ppapi_host.h" | 16 #include "ppapi/host/ppapi_host.h" |
| 17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
| 18 #include "ppapi/proxy/resource_message_params.h" | 18 #include "ppapi/proxy/resource_message_params.h" |
| 19 #include "ppapi/proxy/resource_message_test_sink.h" | 19 #include "ppapi/proxy/resource_message_test_sink.h" |
| 20 #include "ppapi/shared_impl/file_ref_create_info.h" |
| 20 #include "ppapi/shared_impl/ppapi_permissions.h" | 21 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 21 #include "ppapi/shared_impl/ppb_file_ref_shared.h" | |
| 22 #include "ppapi/shared_impl/proxy_lock.h" | 22 #include "ppapi/shared_impl/proxy_lock.h" |
| 23 #include "ppapi/shared_impl/resource_tracker.h" | 23 #include "ppapi/shared_impl/resource_tracker.h" |
| 24 #include "ppapi/shared_impl/test_globals.h" | 24 #include "ppapi/shared_impl/test_globals.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "ui/shell_dialogs/selected_file_info.h" | 26 #include "ui/shell_dialogs/selected_file_info.h" |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 IPC::Message reply_msg; | 116 IPC::Message reply_msg; |
| 117 ASSERT_TRUE(host.sink().GetFirstResourceReplyMatching( | 117 ASSERT_TRUE(host.sink().GetFirstResourceReplyMatching( |
| 118 PpapiPluginMsg_FileChooser_ShowReply::ID, &reply_params, &reply_msg)); | 118 PpapiPluginMsg_FileChooser_ShowReply::ID, &reply_params, &reply_msg)); |
| 119 | 119 |
| 120 // Basic validation of reply. | 120 // Basic validation of reply. |
| 121 EXPECT_EQ(call_params.sequence(), reply_params.sequence()); | 121 EXPECT_EQ(call_params.sequence(), reply_params.sequence()); |
| 122 EXPECT_EQ(PP_OK, reply_params.result()); | 122 EXPECT_EQ(PP_OK, reply_params.result()); |
| 123 PpapiPluginMsg_FileChooser_ShowReply::Schema::Param reply_msg_param; | 123 PpapiPluginMsg_FileChooser_ShowReply::Schema::Param reply_msg_param; |
| 124 ASSERT_TRUE(PpapiPluginMsg_FileChooser_ShowReply::Read(&reply_msg, | 124 ASSERT_TRUE(PpapiPluginMsg_FileChooser_ShowReply::Read(&reply_msg, |
| 125 &reply_msg_param)); | 125 &reply_msg_param)); |
| 126 const std::vector<ppapi::PPB_FileRef_CreateInfo>& chooser_results = | 126 const std::vector<ppapi::FileRefCreateInfo>& chooser_results = |
| 127 reply_msg_param.a; | 127 reply_msg_param.a; |
| 128 ASSERT_EQ(1u, chooser_results.size()); | 128 ASSERT_EQ(1u, chooser_results.size()); |
| 129 // Note path is empty because this is an external filesystem. | |
| 130 EXPECT_EQ(std::string(), chooser_results[0].path); | |
| 131 EXPECT_EQ(FilePathToUTF8(selected_info.display_name), | 129 EXPECT_EQ(FilePathToUTF8(selected_info.display_name), |
| 132 chooser_results[0].name); | 130 chooser_results[0].display_name); |
| 133 } | 131 } |
| 134 | 132 |
| 135 TEST_F(PepperFileChooserHostTest, NoUserGesture) { | 133 TEST_F(PepperFileChooserHostTest, NoUserGesture) { |
| 136 PP_Resource pp_resource = 123; | 134 PP_Resource pp_resource = 123; |
| 137 | 135 |
| 138 MockRendererPpapiHost host(view_, pp_instance()); | 136 MockRendererPpapiHost host(view_, pp_instance()); |
| 139 PepperFileChooserHost chooser(&host, pp_instance(), pp_resource); | 137 PepperFileChooserHost chooser(&host, pp_instance(), pp_resource); |
| 140 | 138 |
| 141 // Say there's no user gesture. | 139 // Say there's no user gesture. |
| 142 host.set_has_user_gesture(false); | 140 host.set_has_user_gesture(false); |
| 143 | 141 |
| 144 std::vector<std::string> accept; | 142 std::vector<std::string> accept; |
| 145 accept.push_back("text/plain"); | 143 accept.push_back("text/plain"); |
| 146 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); | 144 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); |
| 147 | 145 |
| 148 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); | 146 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); |
| 149 ppapi::host::HostMessageContext context(call_params); | 147 ppapi::host::HostMessageContext context(call_params); |
| 150 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); | 148 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); |
| 151 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); | 149 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); |
| 152 } | 150 } |
| 153 | 151 |
| 154 } // namespace content | 152 } // namespace content |
| OLD | NEW |