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

Side by Side Diff: content/renderer/pepper/pepper_file_chooser_host_unittest.cc

Issue 121033002: Update uses of UTF conversions in content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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/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"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 private: 52 private:
53 PP_Instance pp_instance_; 53 PP_Instance pp_instance_;
54 54
55 ppapi::TestGlobals globals_; 55 ppapi::TestGlobals globals_;
56 TestContentClient client_; 56 TestContentClient client_;
57 }; 57 };
58 58
59 // For testing to convert our hardcoded file paths to 8-bit. 59 // For testing to convert our hardcoded file paths to 8-bit.
60 std::string FilePathToUTF8(const base::FilePath::StringType& path) { 60 std::string FilePathToUTF8(const base::FilePath::StringType& path) {
61 #if defined(OS_WIN) 61 #if defined(OS_WIN)
62 return UTF16ToUTF8(path); 62 return base::UTF16ToUTF8(path);
63 #else 63 #else
64 return path; 64 return path;
65 #endif 65 #endif
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 TEST_F(PepperFileChooserHostTest, Show) { 70 TEST_F(PepperFileChooserHostTest, Show) {
71 PP_Resource pp_resource = 123; 71 PP_Resource pp_resource = 123;
72 72
(...skipping 17 matching lines...) Expand all
90 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 90 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
91 ViewHostMsg_RunFileChooser::ID); 91 ViewHostMsg_RunFileChooser::ID);
92 ASSERT_TRUE(msg); 92 ASSERT_TRUE(msg);
93 ViewHostMsg_RunFileChooser::Schema::Param call_msg_param; 93 ViewHostMsg_RunFileChooser::Schema::Param call_msg_param;
94 ASSERT_TRUE(ViewHostMsg_RunFileChooser::Read(msg, &call_msg_param)); 94 ASSERT_TRUE(ViewHostMsg_RunFileChooser::Read(msg, &call_msg_param));
95 const FileChooserParams& chooser_params = call_msg_param.a; 95 const FileChooserParams& chooser_params = call_msg_param.a;
96 96
97 // Basic validation of request. 97 // Basic validation of request.
98 EXPECT_EQ(FileChooserParams::Open, chooser_params.mode); 98 EXPECT_EQ(FileChooserParams::Open, chooser_params.mode);
99 ASSERT_EQ(1u, chooser_params.accept_types.size()); 99 ASSERT_EQ(1u, chooser_params.accept_types.size());
100 EXPECT_EQ(accept[0], UTF16ToUTF8(chooser_params.accept_types[0])); 100 EXPECT_EQ(accept[0], base::UTF16ToUTF8(chooser_params.accept_types[0]));
101 101
102 // Send a chooser reply to the render view. Note our reply path has to have a 102 // Send a chooser reply to the render view. Note our reply path has to have a
103 // path separator so we include both a Unix and a Windows one. 103 // path separator so we include both a Unix and a Windows one.
104 ui::SelectedFileInfo selected_info; 104 ui::SelectedFileInfo selected_info;
105 selected_info.display_name = FILE_PATH_LITERAL("Hello, world"); 105 selected_info.display_name = FILE_PATH_LITERAL("Hello, world");
106 selected_info.local_path = base::FilePath(FILE_PATH_LITERAL("myp\\ath/foo")); 106 selected_info.local_path = base::FilePath(FILE_PATH_LITERAL("myp\\ath/foo"));
107 std::vector<ui::SelectedFileInfo> selected_info_vector; 107 std::vector<ui::SelectedFileInfo> selected_info_vector;
108 selected_info_vector.push_back(selected_info); 108 selected_info_vector.push_back(selected_info);
109 RenderViewImpl* view_impl = static_cast<RenderViewImpl*>(view_); 109 RenderViewImpl* view_impl = static_cast<RenderViewImpl*>(view_);
110 ViewMsg_RunFileChooserResponse response(view_impl->routing_id(), 110 ViewMsg_RunFileChooserResponse response(view_impl->routing_id(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 accept.push_back("text/plain"); 143 accept.push_back("text/plain");
144 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); 144 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept);
145 145
146 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); 146 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0);
147 ppapi::host::HostMessageContext context(call_params); 147 ppapi::host::HostMessageContext context(call_params);
148 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); 148 int32 result = chooser.OnResourceMessageReceived(show_msg, &context);
149 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); 149 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result);
150 } 150 }
151 151
152 } // namespace content 152 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_file_chooser_host.cc ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698