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

Side by Side Diff: ppapi/proxy/ppapi_proxy_test.h

Issue 10544089: Implement the file chooser as a new resource "host" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "ipc/ipc_test_sink.h"
13 #include "ppapi/c/pp_instance.h" 12 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/proxy/host_dispatcher.h" 13 #include "ppapi/proxy/host_dispatcher.h"
15 #include "ppapi/proxy/plugin_dispatcher.h" 14 #include "ppapi/proxy/plugin_dispatcher.h"
16 #include "ppapi/proxy/plugin_globals.h" 15 #include "ppapi/proxy/plugin_globals.h"
17 #include "ppapi/proxy/plugin_proxy_delegate.h" 16 #include "ppapi/proxy/plugin_proxy_delegate.h"
18 #include "ppapi/proxy/plugin_resource_tracker.h" 17 #include "ppapi/proxy/plugin_resource_tracker.h"
19 #include "ppapi/proxy/plugin_var_tracker.h" 18 #include "ppapi/proxy/plugin_var_tracker.h"
19 #include "ppapi/proxy/resource_message_test_sink.h"
20 #include "ppapi/shared_impl/test_globals.h" 20 #include "ppapi/shared_impl/test_globals.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace ppapi { 23 namespace ppapi {
24 namespace proxy { 24 namespace proxy {
25 25
26 // Base class for plugin and host test harnesses. Tests will not use this 26 // Base class for plugin and host test harnesses. Tests will not use this
27 // directly. Instead, use the PluginProxyTest, HostProxyTest, or TwoWayTest. 27 // directly. Instead, use the PluginProxyTest, HostProxyTest, or TwoWayTest.
28 class ProxyTestHarnessBase { 28 class ProxyTestHarnessBase {
29 public: 29 public:
30 ProxyTestHarnessBase(); 30 ProxyTestHarnessBase();
31 virtual ~ProxyTestHarnessBase(); 31 virtual ~ProxyTestHarnessBase();
32 32
33 PP_Module pp_module() const { return pp_module_; } 33 PP_Module pp_module() const { return pp_module_; }
34 PP_Instance pp_instance() const { return pp_instance_; } 34 PP_Instance pp_instance() const { return pp_instance_; }
35 IPC::TestSink& sink() { return sink_; } 35 ResourceMessageTestSink& sink() { return sink_; }
36 36
37 virtual PpapiGlobals* GetGlobals() = 0; 37 virtual PpapiGlobals* GetGlobals() = 0;
38 // Returns either the plugin or host dispatcher, depending on the test. 38 // Returns either the plugin or host dispatcher, depending on the test.
39 virtual Dispatcher* GetDispatcher() = 0; 39 virtual Dispatcher* GetDispatcher() = 0;
40 40
41 // Set up the harness using an IPC::TestSink to capture messages. 41 // Set up the harness using an IPC::TestSink to capture messages.
42 virtual void SetUpHarness() = 0; 42 virtual void SetUpHarness() = 0;
43 43
44 // Set up the harness using a real IPC channel. 44 // Set up the harness using a real IPC channel.
45 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, 45 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle,
(...skipping 12 matching lines...) Expand all
58 // interface name. This will be returned when any of the proxy logic 58 // interface name. This will be returned when any of the proxy logic
59 // requests a local interface. 59 // requests a local interface.
60 void RegisterTestInterface(const char* name, const void* test_interface); 60 void RegisterTestInterface(const char* name, const void* test_interface);
61 61
62 // Sends a "supports interface" message to the current dispatcher and returns 62 // Sends a "supports interface" message to the current dispatcher and returns
63 // true if it's supported. This is just for the convenience of tests. 63 // true if it's supported. This is just for the convenience of tests.
64 bool SupportsInterface(const char* name); 64 bool SupportsInterface(const char* name);
65 65
66 private: 66 private:
67 // Destination for IPC messages sent by the test. 67 // Destination for IPC messages sent by the test.
68 IPC::TestSink sink_; 68 ResourceMessageTestSink sink_;
69 69
70 // The module and instance ID associated with the plugin dispatcher. 70 // The module and instance ID associated with the plugin dispatcher.
71 PP_Module pp_module_; 71 PP_Module pp_module_;
72 PP_Instance pp_instance_; 72 PP_Instance pp_instance_;
73 73
74 // Stores the data for GetInterface/RegisterTestInterface. 74 // Stores the data for GetInterface/RegisterTestInterface.
75 std::map<std::string, const void*> registered_interfaces_; 75 std::map<std::string, const void*> registered_interfaces_;
76 }; 76 };
77 77
78 // Test harness for the plugin side of the proxy. 78 // Test harness for the plugin side of the proxy.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // interface, remote_harness will point to plugin_, and local_harness 264 // interface, remote_harness will point to plugin_, and local_harness
265 // will point to host_. This makes it convenient when we're starting and 265 // will point to host_. This makes it convenient when we're starting and
266 // stopping the harnesses. 266 // stopping the harnesses.
267 ProxyTestHarnessBase* remote_harness_; 267 ProxyTestHarnessBase* remote_harness_;
268 ProxyTestHarnessBase* local_harness_; 268 ProxyTestHarnessBase* local_harness_;
269 269
270 base::WaitableEvent channel_created_; 270 base::WaitableEvent channel_created_;
271 base::WaitableEvent shutdown_event_; 271 base::WaitableEvent shutdown_event_;
272 }; 272 };
273 273
274 // Used during Gtests when you have a PP_Var that you want to EXPECT is equal
275 // to a certain constant string value:
276 //
277 // EXPECT_VAR_IS_STRING("foo", my_var);
278 #define EXPECT_VAR_IS_STRING(str, var) { \
279 StringVar* sv = StringVar::FromPPVar(var); \
280 EXPECT_TRUE(sv); \
281 if (sv) \
282 EXPECT_EQ(str, sv->value()); \
283 }
284
274 } // namespace proxy 285 } // namespace proxy
275 } // namespace ppapi 286 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698