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/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/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 13 matching lines...) Expand all Loading... |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "ui/shell_dialogs/selected_file_info.h" | 25 #include "ui/shell_dialogs/selected_file_info.h" |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 class PepperFileChooserHostTest : public RenderViewTest { | 31 class PepperFileChooserHostTest : public RenderViewTest { |
32 public: | 32 public: |
33 PepperFileChooserHostTest() | 33 PepperFileChooserHostTest() |
34 : pp_instance_(123456), | 34 : pp_instance_(123456) {} |
35 old_content_client_(NULL) {} | |
36 | 35 |
37 virtual void SetUp() { | 36 virtual void SetUp() { |
38 old_content_client_ = GetContentClient(); | |
39 SetContentClient(&client_); | 37 SetContentClient(&client_); |
40 RenderViewTest::SetUp(); | 38 RenderViewTest::SetUp(); |
41 | 39 |
42 globals_.GetResourceTracker()->DidCreateInstance(pp_instance_); | 40 globals_.GetResourceTracker()->DidCreateInstance(pp_instance_); |
43 } | 41 } |
44 virtual void TearDown() { | 42 virtual void TearDown() { |
45 globals_.GetResourceTracker()->DidDeleteInstance(pp_instance_); | 43 globals_.GetResourceTracker()->DidDeleteInstance(pp_instance_); |
46 | 44 |
47 RenderViewTest::TearDown(); | 45 RenderViewTest::TearDown(); |
48 SetContentClient(old_content_client_); | |
49 } | 46 } |
50 | 47 |
51 PP_Instance pp_instance() const { return pp_instance_; } | 48 PP_Instance pp_instance() const { return pp_instance_; } |
52 | 49 |
53 private: | 50 private: |
54 PP_Instance pp_instance_; | 51 PP_Instance pp_instance_; |
55 | 52 |
56 ppapi::TestGlobals globals_; | 53 ppapi::TestGlobals globals_; |
57 TestContentClient client_; | 54 TestContentClient client_; |
58 | |
59 // Original value for the content client. | |
60 ContentClient* old_content_client_; | |
61 }; | 55 }; |
62 | 56 |
63 // For testing to convert our hardcoded file paths to 8-bit. | 57 // For testing to convert our hardcoded file paths to 8-bit. |
64 std::string FilePathToUTF8(const base::FilePath::StringType& path) { | 58 std::string FilePathToUTF8(const base::FilePath::StringType& path) { |
65 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
66 return UTF16ToUTF8(path); | 60 return UTF16ToUTF8(path); |
67 #else | 61 #else |
68 return path; | 62 return path; |
69 #endif | 63 #endif |
70 } | 64 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 accept.push_back("text/plain"); | 143 accept.push_back("text/plain"); |
150 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); | 144 PpapiHostMsg_FileChooser_Show show_msg(false, false, std::string(), accept); |
151 | 145 |
152 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); | 146 ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 0); |
153 ppapi::host::HostMessageContext context(call_params); | 147 ppapi::host::HostMessageContext context(call_params); |
154 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); | 148 int32 result = chooser.OnResourceMessageReceived(show_msg, &context); |
155 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); | 149 EXPECT_EQ(PP_ERROR_NO_USER_GESTURE, result); |
156 } | 150 } |
157 | 151 |
158 } // namespace content | 152 } // namespace content |
OLD | NEW |