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

Side by Side Diff: ppapi/proxy/serialized_var_unittest.cc

Issue 6334016: Refactor PPAPI proxy resource handling to maintain which host they came from,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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
« no previous file with comments | « ppapi/proxy/serialized_var.cc ('k') | ppapi/proxy/var_serialization_rules.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/proxy/ppapi_proxy_test.h"
6
7 #include "ppapi/proxy/serialized_var.h"
8
9 namespace pp {
10 namespace proxy {
11
12 namespace {
13
14 PP_Var MakeStringVar(int64_t string_id) {
15 PP_Var ret;
16 ret.type = PP_VARTYPE_STRING;
17 ret.value.as_id = string_id;
18 return ret;
19 }
20
21 PP_Var MakeObjectVar(int64_t object_id) {
22 PP_Var ret;
23 ret.type = PP_VARTYPE_OBJECT;
24 ret.value.as_id = object_id;
25 return ret;
26 }
27
28 class SerializedVarTest : public PluginProxyTest {
29 public:
30 SerializedVarTest() {}
31 };
32
33 } // namespace
34
35 // Tests output arguments.
36 TEST_F(SerializedVarTest, PluginSerializedVarOutParam) {
37 PP_Var host_object = MakeObjectVar(0x31337);
38
39 // Start tracking this object in the plugin.
40 PP_Var plugin_object = var_tracker().ReceiveObjectPassRef(
41 host_object, plugin_dispatcher());
42 EXPECT_EQ(1, var_tracker().GetRefCountForObject(plugin_object));
43
44 {
45 SerializedVar sv;
46 {
47 // The "OutParam" does its work in its destructor, it will write the
48 // information to the SerializedVar we passed in the constructor.
49 SerializedVarOutParam out_param(&sv);
50 *out_param.OutParam(plugin_dispatcher()) = plugin_object;
51 }
52
53 // The object should have transformed the plugin object back to the host
54 // object ID. Nothing in the var tracker should have changed yet, and no
55 // messages should have been sent.
56 SerializedVarTestReader reader(sv);
57 EXPECT_EQ(host_object.value.as_id, reader.GetIncompleteVar().value.as_id);
58 EXPECT_EQ(1, var_tracker().GetRefCountForObject(plugin_object));
59 EXPECT_EQ(0u, sink().message_count());
60 }
61
62 // The out param should have done an "end send pass ref" on the plugin
63 // var serialization rules, which should have in turn released the reference
64 // in the var tracker. Since we only had one reference, this should have sent
65 // a release to the browser.
66 EXPECT_EQ(-1, var_tracker().GetRefCountForObject(plugin_object));
67 EXPECT_EQ(1u, sink().message_count());
68
69 // We don't bother validating that message since it's nontrivial and the
70 // PluginVarTracker test has cases that cover that this message is correct.
71 }
72
73 } // namespace proxy
74 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/serialized_var.cc ('k') | ppapi/proxy/var_serialization_rules.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698