| 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" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 PP_Instance pp_instance_; | 54 PP_Instance pp_instance_; |
| 55 | 55 |
| 56 ppapi::TestGlobals globals_; | 56 ppapi::TestGlobals globals_; |
| 57 TestContentClient client_; | 57 TestContentClient client_; |
| 58 | 58 |
| 59 // Original value for the content client. | 59 // Original value for the content client. |
| 60 ContentClient* old_content_client_; | 60 ContentClient* old_content_client_; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // For testing to convert our hardcoded file paths to 8-bit. | 63 // For testing to convert our hardcoded file paths to 8-bit. |
| 64 std::string FilePathToUTF8(const FilePath::StringType& path) { | 64 std::string FilePathToUTF8(const base::FilePath::StringType& path) { |
| 65 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
| 66 return UTF16ToUTF8(path); | 66 return UTF16ToUTF8(path); |
| 67 #else | 67 #else |
| 68 return path; | 68 return path; |
| 69 #endif | 69 #endif |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace | 72 } // namespace |
| 73 | 73 |
| 74 TEST_F(PepperFileChooserHostTest, Show) { | 74 TEST_F(PepperFileChooserHostTest, Show) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 100 | 100 |
| 101 // Basic validation of request. | 101 // Basic validation of request. |
| 102 EXPECT_EQ(FileChooserParams::Open, chooser_params.mode); | 102 EXPECT_EQ(FileChooserParams::Open, chooser_params.mode); |
| 103 ASSERT_EQ(1u, chooser_params.accept_types.size()); | 103 ASSERT_EQ(1u, chooser_params.accept_types.size()); |
| 104 EXPECT_EQ(accept[0], UTF16ToUTF8(chooser_params.accept_types[0])); | 104 EXPECT_EQ(accept[0], UTF16ToUTF8(chooser_params.accept_types[0])); |
| 105 | 105 |
| 106 // Send a chooser reply to the render view. Note our reply path has to have a | 106 // 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. | 107 // path separator so we include both a Unix and a Windows one. |
| 108 ui::SelectedFileInfo selected_info; | 108 ui::SelectedFileInfo selected_info; |
| 109 selected_info.display_name = FILE_PATH_LITERAL("Hello, world"); | 109 selected_info.display_name = FILE_PATH_LITERAL("Hello, world"); |
| 110 selected_info.local_path = FilePath(FILE_PATH_LITERAL("myp\\ath/foo")); | 110 selected_info.local_path = base::FilePath(FILE_PATH_LITERAL("myp\\ath/foo")); |
| 111 std::vector<ui::SelectedFileInfo> selected_info_vector; | 111 std::vector<ui::SelectedFileInfo> selected_info_vector; |
| 112 selected_info_vector.push_back(selected_info); | 112 selected_info_vector.push_back(selected_info); |
| 113 RenderViewImpl* view_impl = static_cast<RenderViewImpl*>(view_); | 113 RenderViewImpl* view_impl = static_cast<RenderViewImpl*>(view_); |
| 114 ViewMsg_RunFileChooserResponse response(view_impl->routing_id(), | 114 ViewMsg_RunFileChooserResponse response(view_impl->routing_id(), |
| 115 selected_info_vector); | 115 selected_info_vector); |
| 116 EXPECT_TRUE(view_impl->OnMessageReceived(response)); | 116 EXPECT_TRUE(view_impl->OnMessageReceived(response)); |
| 117 | 117 |
| 118 // This should have sent the Pepper reply to our test sink. | 118 // This should have sent the Pepper reply to our test sink. |
| 119 ppapi::proxy::ResourceMessageReplyParams reply_params; | 119 ppapi::proxy::ResourceMessageReplyParams reply_params; |
| 120 IPC::Message reply_msg; | 120 IPC::Message reply_msg; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 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 |