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 <stdint.h> | 5 #include <stdint.h> |
6 #include <tuple> | 6 #include <tuple> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "content/common/frame_messages.h" |
11 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
12 #include "content/public/common/file_chooser_file_info.h" | 13 #include "content/public/common/file_chooser_file_info.h" |
13 #include "content/public/common/file_chooser_params.h" | 14 #include "content/public/common/file_chooser_params.h" |
14 #include "content/public/test/render_view_test.h" | 15 #include "content/public/test/render_view_test.h" |
15 #include "content/renderer/pepper/mock_renderer_ppapi_host.h" | 16 #include "content/renderer/pepper/mock_renderer_ppapi_host.h" |
16 #include "content/renderer/pepper/pepper_file_chooser_host.h" | 17 #include "content/renderer/pepper/pepper_file_chooser_host.h" |
17 #include "content/renderer/render_view_impl.h" | 18 #include "content/renderer/render_view_impl.h" |
18 #include "content/test/test_content_client.h" | 19 #include "content/test/test_content_client.h" |
19 #include "ppapi/c/pp_errors.h" | 20 #include "ppapi/c/pp_errors.h" |
20 #include "ppapi/host/host_message_context.h" | 21 #include "ppapi/host/host_message_context.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); | 86 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); |
86 | 87 |
87 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); | 88 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); |
88 ppapi::host::HostMessageContext context(call_params); | 89 ppapi::host::HostMessageContext context(call_params); |
89 int32_t result = chooser.OnResourceMessageReceived(show_msg, &context); | 90 int32_t result = chooser.OnResourceMessageReceived(show_msg, &context); |
90 EXPECT_EQ(PP_OK_COMPLETIONPENDING, result); | 91 EXPECT_EQ(PP_OK_COMPLETIONPENDING, result); |
91 | 92 |
92 // The render view should have sent a chooser request to the browser | 93 // The render view should have sent a chooser request to the browser |
93 // (caught by the render thread's test message sink). | 94 // (caught by the render thread's test message sink). |
94 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 95 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
95 ViewHostMsg_RunFileChooser::ID); | 96 FrameHostMsg_RunFileChooser::ID); |
96 ASSERT_TRUE(msg); | 97 ASSERT_TRUE(msg); |
97 ViewHostMsg_RunFileChooser::Schema::Param call_msg_param; | 98 FrameHostMsg_RunFileChooser::Schema::Param call_msg_param; |
98 ASSERT_TRUE(ViewHostMsg_RunFileChooser::Read(msg, &call_msg_param)); | 99 ASSERT_TRUE(FrameHostMsg_RunFileChooser::Read(msg, &call_msg_param)); |
99 const FileChooserParams& chooser_params = std::get<0>(call_msg_param); | 100 const FileChooserParams& chooser_params = std::get<0>(call_msg_param); |
100 | 101 |
101 // Basic validation of request. | 102 // Basic validation of request. |
102 EXPECT_EQ(FileChooserParams::Open, chooser_params.mode); | 103 EXPECT_EQ(FileChooserParams::Open, chooser_params.mode); |
103 ASSERT_EQ(1u, chooser_params.accept_types.size()); | 104 ASSERT_EQ(1u, chooser_params.accept_types.size()); |
104 EXPECT_EQ(accept[0], base::UTF16ToUTF8(chooser_params.accept_types[0])); | 105 EXPECT_EQ(accept[0], base::UTF16ToUTF8(chooser_params.accept_types[0])); |
105 | 106 |
106 // Send a chooser reply to the render view. Note our reply path has to have a | 107 // Send a chooser reply to the render view. Note our reply path has to have a |
107 // path separator so we include both a Unix and a Windows one. | 108 // path separator so we include both a Unix and a Windows one. |
108 content::FileChooserFileInfo selected_info; | 109 content::FileChooserFileInfo selected_info; |
109 selected_info.display_name = FILE_PATH_LITERAL("Hello, world"); | 110 selected_info.display_name = FILE_PATH_LITERAL("Hello, world"); |
110 selected_info.file_path = base::FilePath(FILE_PATH_LITERAL("myp\\ath/foo")); | 111 selected_info.file_path = base::FilePath(FILE_PATH_LITERAL("myp\\ath/foo")); |
111 std::vector<content::FileChooserFileInfo> selected_info_vector; | 112 std::vector<content::FileChooserFileInfo> selected_info_vector; |
112 selected_info_vector.push_back(selected_info); | 113 selected_info_vector.push_back(selected_info); |
113 RenderViewImpl* view_impl = static_cast<RenderViewImpl*>(view_); | 114 RenderFrameImpl* frame_impl = |
114 ViewMsg_RunFileChooserResponse response(view_impl->GetRoutingID(), | 115 static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()); |
115 selected_info_vector); | 116 FrameMsg_RunFileChooserResponse response(frame_impl->GetRoutingID(), |
116 EXPECT_TRUE(view_impl->OnMessageReceived(response)); | 117 selected_info_vector); |
| 118 EXPECT_TRUE(frame_impl->OnMessageReceived(response)); |
117 | 119 |
118 // This should have sent the Pepper reply to our test sink. | 120 // This should have sent the Pepper reply to our test sink. |
119 ppapi::proxy::ResourceMessageReplyParams reply_params; | 121 ppapi::proxy::ResourceMessageReplyParams reply_params; |
120 IPC::Message reply_msg; | 122 IPC::Message reply_msg; |
121 ASSERT_TRUE(host.sink().GetFirstResourceReplyMatching( | 123 ASSERT_TRUE(host.sink().GetFirstResourceReplyMatching( |
122 PpapiPluginMsg_FileChooser_ShowReply::ID, &reply_params, &reply_msg)); | 124 PpapiPluginMsg_FileChooser_ShowReply::ID, &reply_params, &reply_msg)); |
123 | 125 |
124 // Basic validation of reply. | 126 // Basic validation of reply. |
125 EXPECT_EQ(call_params.sequence(), reply_params.sequence()); | 127 EXPECT_EQ(call_params.sequence(), reply_params.sequence()); |
126 EXPECT_EQ(PP_OK, reply_params.result()); | 128 EXPECT_EQ(PP_OK, reply_params.result()); |
(...skipping 20 matching lines...) Expand all Loading... |
147 accept.push_back("text/plain"); | 149 accept.push_back("text/plain"); |
148 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); | 150 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); |
149 | 151 |
150 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); | 152 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); |
151 ppapi::host::HostMessageContext context(call_params); | 153 ppapi::host::HostMessageContext context(call_params); |
152 int32_t result = chooser.OnResourceMessageReceived(show_msg, &context); | 154 int32_t result = chooser.OnResourceMessageReceived(show_msg, &context); |
153 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); | 155 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); |
154 } | 156 } |
155 | 157 |
156 } // namespace content | 158 } // namespace content |
OLD | NEW |