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

Side by Side Diff: core/cross/client_info_test.cc

Issue 155276: Add ClientInfo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 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
(Empty)
1 /*
2 * Copyright 2009, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32
33 // This file implements unit tests for class ClientInfoManager.
34
35 #include "core/cross/client.h"
36 #include "tests/common/win/testing_common.h"
37 #include "core/cross/client_info.h"
38
39 namespace o3d {
40
41 class ClientInfoManagerTest : public testing::Test {
42 public:
43 ServiceLocator* service_locator() {
44 return service_locator_;
45 }
46
47 protected:
48 ClientInfoManagerTest() { }
49
50 virtual void SetUp() {
51 // We need to create a new SerivceLocator because the global one
52 // already has a global ClientInfoManager object registered on it.
53 service_locator_ = new ServiceLocator;
54 object_manager_ = new ObjectManager(service_locator_);
55 }
56
57 virtual void TearDown() {
58 delete object_manager_;
59 delete service_locator_;
60 }
61
62 ServiceLocator* service_locator_;
63 ObjectManager* object_manager_;
64 };
65
66 TEST_F(ClientInfoManagerTest, Basic) {
67 ClientInfoManager* client_info_manager =
68 new ClientInfoManager(service_locator());
69
70 // Check that the client_info_manager start off correctly.
71 EXPECT_EQ(0, client_info_manager->client_info().texture_memory_used());
72 EXPECT_EQ(0, client_info_manager->client_info().buffer_memory_used());
73 EXPECT_EQ(0, client_info_manager->client_info().num_objects());
74 EXPECT_FALSE(client_info_manager->client_info().software_renderer());
75
76 delete client_info_manager;
77 }
78
79 TEST_F(ClientInfoManagerTest, AdjustTextureMemoryUsed) {
80 ClientInfoManager* client_info_manager =
81 new ClientInfoManager(service_locator());
82
83 client_info_manager->AdjustTextureMemoryUsed(10);
84 EXPECT_EQ(10, client_info_manager->client_info().texture_memory_used());
85 client_info_manager->AdjustTextureMemoryUsed(10);
86 EXPECT_EQ(20, client_info_manager->client_info().texture_memory_used());
87 client_info_manager->AdjustTextureMemoryUsed(-10);
88 EXPECT_EQ(10, client_info_manager->client_info().texture_memory_used());
89 client_info_manager->AdjustTextureMemoryUsed(-10);
90 EXPECT_EQ(0, client_info_manager->client_info().texture_memory_used());
91
92 delete client_info_manager;
93 }
94
95 TEST_F(ClientInfoManagerTest, AdjustBufferMemoryUsed) {
96 ClientInfoManager* client_info_manager =
97 new ClientInfoManager(service_locator());
98
99 client_info_manager->AdjustBufferMemoryUsed(10);
100 EXPECT_EQ(10, client_info_manager->client_info().buffer_memory_used());
101 client_info_manager->AdjustBufferMemoryUsed(10);
102 EXPECT_EQ(20, client_info_manager->client_info().buffer_memory_used());
103 client_info_manager->AdjustBufferMemoryUsed(-10);
104 EXPECT_EQ(10, client_info_manager->client_info().buffer_memory_used());
105 client_info_manager->AdjustBufferMemoryUsed(-10);
106 EXPECT_EQ(0, client_info_manager->client_info().buffer_memory_used());
107
108 delete client_info_manager;
109 }
110
111 /*
apatrick 2009/07/09 18:22:00 This is commented out.
112 TEST_F(ClientInfoManagerTest, SetNumObjects) {
113 ClientInfoManager* client_info_manager =
114 new ClientInfoManager(service_locator());
115
116 client_info_manager->SetNumObjects(10);
117 EXPECT_EQ(10, client_info_manager->client_info().num_objects());
118 client_info_manager->SetNumObjects(20);
119 EXPECT_EQ(20, client_info_manager->client_info().num_objects());
120
121 delete client_info_manager;
122 }
123 */
124
125 TEST_F(ClientInfoManagerTest, SetSoftwareRenderer) {
126 ClientInfoManager* client_info_manager =
127 new ClientInfoManager(service_locator());
128
129 client_info_manager->SetSoftwareRenderer(true);
130 EXPECT_TRUE(client_info_manager->client_info().software_renderer());
131 client_info_manager->SetSoftwareRenderer(false);
132 EXPECT_FALSE(client_info_manager->client_info().software_renderer());
133
134 delete client_info_manager;
135 }
136
137 } // namespace o3d
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698