Infobar material design refresh: bg color
[chromium-blink-merge.git] / gpu / command_buffer / service / id_manager_unittest.cc
blob9a6e56776528db7de6d00486aafd059e5e9ce2c4
1 // Copyright (c) 2010 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.
5 #include "gpu/command_buffer/service/id_manager.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace gpu {
9 namespace gles2 {
11 class IdManagerTest : public testing::Test {
12 public:
13 IdManagerTest() {
16 protected:
17 void SetUp() override {}
19 void TearDown() override {}
21 IdManager manager_;
24 TEST_F(IdManagerTest, Basic) {
25 const GLuint kClientId1 = 1;
26 const GLuint kClientId2 = 2;
27 const GLuint kServiceId1 = 201;
28 const GLuint kServiceId2 = 202;
29 // Check we can add an id
30 EXPECT_TRUE(manager_.AddMapping(kClientId1, kServiceId1));
31 // Check we can get that mapping
32 GLuint service_id = 0;
33 EXPECT_TRUE(manager_.GetServiceId(kClientId1, &service_id));
34 EXPECT_EQ(kServiceId1, service_id);
35 GLuint client_id = 0;
36 EXPECT_TRUE(manager_.GetClientId(kServiceId1, &client_id));
37 EXPECT_EQ(kClientId1, client_id);
38 // Check that it fails if we get a non-existent id.
39 service_id = 0;
40 client_id = 0;
41 EXPECT_FALSE(manager_.GetServiceId(kClientId2, &service_id));
42 EXPECT_FALSE(manager_.GetClientId(kServiceId2, &client_id));
43 EXPECT_EQ(0u, service_id);
44 EXPECT_EQ(0u, client_id);
45 // Check we can add a second id.
46 EXPECT_TRUE(manager_.AddMapping(kClientId2, kServiceId2));
47 // Check we can get that mapping
48 service_id = 0;
49 EXPECT_TRUE(manager_.GetServiceId(kClientId1, &service_id));
50 EXPECT_EQ(kServiceId1, service_id);
51 EXPECT_TRUE(manager_.GetServiceId(kClientId2, &service_id));
52 EXPECT_EQ(kServiceId2, service_id);
53 client_id = 0;
54 EXPECT_TRUE(manager_.GetClientId(kServiceId1, &client_id));
55 EXPECT_EQ(kClientId1, client_id);
56 EXPECT_TRUE(manager_.GetClientId(kServiceId2, &client_id));
57 EXPECT_EQ(kClientId2, client_id);
58 // Check if we remove an id we can no longer get it.
59 EXPECT_TRUE(manager_.RemoveMapping(kClientId1, kServiceId1));
60 EXPECT_FALSE(manager_.GetServiceId(kClientId1, &service_id));
61 EXPECT_FALSE(manager_.GetClientId(kServiceId1, &client_id));
62 // Check we get an error if we try to remove a non-existent id.
63 EXPECT_FALSE(manager_.RemoveMapping(kClientId1, kServiceId1));
64 EXPECT_FALSE(manager_.RemoveMapping(kClientId2, kServiceId1));
65 EXPECT_FALSE(manager_.RemoveMapping(kClientId1, kServiceId2));
66 // Check we get an error if we try to map an existing id.
67 EXPECT_FALSE(manager_.AddMapping(kClientId2, kServiceId2));
68 EXPECT_FALSE(manager_.AddMapping(kClientId2, kServiceId1));
71 } // namespace gles2
72 } // namespace gpu