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

Side by Side Diff: ppapi/shared_impl/var_tracker_unittest.cc

Issue 174213003: PPAPI: Use clang-format on ppapi/shared_impl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove DEPS Created 6 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
« no previous file with comments | « ppapi/shared_impl/var_tracker.cc ('k') | ppapi/shared_impl/var_value_conversions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "ppapi/shared_impl/proxy_lock.h" 8 #include "ppapi/shared_impl/proxy_lock.h"
9 #include "ppapi/shared_impl/var.h" 9 #include "ppapi/shared_impl/var.h"
10 #include "ppapi/shared_impl/var_tracker.h" 10 #include "ppapi/shared_impl/var_tracker.h"
11 #include "ppapi/shared_impl/test_globals.h" 11 #include "ppapi/shared_impl/test_globals.h"
12 12
13 namespace ppapi { 13 namespace ppapi {
14 14
15 namespace { 15 namespace {
16 16
17 int mock_var_alive_count = 0; 17 int mock_var_alive_count = 0;
18 18
19 class MockStringVar : public StringVar { 19 class MockStringVar : public StringVar {
20 public: 20 public:
21 MockStringVar(const std::string& str) : StringVar(str) { 21 MockStringVar(const std::string& str) : StringVar(str) {
22 mock_var_alive_count++; 22 mock_var_alive_count++;
23 } 23 }
24 virtual ~MockStringVar() { 24 virtual ~MockStringVar() { mock_var_alive_count--; }
25 mock_var_alive_count--; 25 bool HasValidVarID() { return GetExistingVarID() != 0; }
26 }
27 bool HasValidVarID() {
28 return GetExistingVarID() != 0;
29 }
30 }; 26 };
31 27
32 class MockObjectVar : public Var { 28 class MockObjectVar : public Var {
33 public: 29 public:
34 MockObjectVar() : Var() { 30 MockObjectVar() : Var() { mock_var_alive_count++; }
35 mock_var_alive_count++; 31 virtual ~MockObjectVar() { mock_var_alive_count--; }
36 } 32 virtual PP_VarType GetType() const OVERRIDE { return PP_VARTYPE_OBJECT; }
37 virtual ~MockObjectVar() { 33 bool HasValidVarID() { return GetExistingVarID() != 0; }
38 mock_var_alive_count--;
39 }
40 virtual PP_VarType GetType() const OVERRIDE {
41 return PP_VARTYPE_OBJECT;
42 }
43 bool HasValidVarID() {
44 return GetExistingVarID() != 0;
45 }
46 }; 34 };
47 35
48 } // namespace 36 } // namespace
49 37
50 class VarTrackerTest : public testing::Test { 38 class VarTrackerTest : public testing::Test {
51 public: 39 public:
52 VarTrackerTest() {} 40 VarTrackerTest() {}
53 41
54 // Test implementation. 42 // Test implementation.
55 virtual void SetUp() OVERRIDE { 43 virtual void SetUp() OVERRIDE {
56 ASSERT_EQ(0, mock_var_alive_count); 44 ASSERT_EQ(0, mock_var_alive_count);
57 ProxyLock::EnableLockingOnThreadForTest(); 45 ProxyLock::EnableLockingOnThreadForTest();
58 } 46 }
59 virtual void TearDown() OVERRIDE { 47 virtual void TearDown() OVERRIDE {}
60 }
61 48
62 VarTracker& var_tracker() { return *globals_.GetVarTracker(); } 49 VarTracker& var_tracker() { return *globals_.GetVarTracker(); }
63 50
64 private: 51 private:
65 TestGlobals globals_; 52 TestGlobals globals_;
66 }; 53 };
67 54
68 // Test that ResetVarID is called when the last PP_Var ref was deleted but the 55 // Test that ResetVarID is called when the last PP_Var ref was deleted but the
69 // object lives on. 56 // object lives on.
70 TEST_F(VarTrackerTest, LastResourceRef) { 57 TEST_F(VarTrackerTest, LastResourceRef) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 another_var = NULL; 143 another_var = NULL;
157 EXPECT_TRUE(var_tracker().GetVar(pp_var)); 144 EXPECT_TRUE(var_tracker().GetVar(pp_var));
158 EXPECT_EQ(1, mock_var_alive_count); 145 EXPECT_EQ(1, mock_var_alive_count);
159 146
160 // Releasing plugin reference. 147 // Releasing plugin reference.
161 EXPECT_TRUE(var_tracker().ReleaseVar(pp_var)); 148 EXPECT_TRUE(var_tracker().ReleaseVar(pp_var));
162 EXPECT_EQ(0, mock_var_alive_count); 149 EXPECT_EQ(0, mock_var_alive_count);
163 } 150 }
164 151
165 } // namespace ppapi 152 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/var_tracker.cc ('k') | ppapi/shared_impl/var_value_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698