This source file includes following definitions.
- SetUp
- TearDown
- TEST_F
#include "gpu/command_buffer/service/id_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gpu {
namespace gles2 {
class IdManagerTest : public testing::Test {
public:
IdManagerTest() {
}
protected:
virtual void SetUp() {
}
virtual void TearDown() {
}
IdManager manager_;
};
TEST_F(IdManagerTest, Basic) {
const GLuint kClientId1 = 1;
const GLuint kClientId2 = 2;
const GLuint kServiceId1 = 201;
const GLuint kServiceId2 = 202;
EXPECT_TRUE(manager_.AddMapping(kClientId1, kServiceId1));
GLuint service_id = 0;
EXPECT_TRUE(manager_.GetServiceId(kClientId1, &service_id));
EXPECT_EQ(kServiceId1, service_id);
GLuint client_id = 0;
EXPECT_TRUE(manager_.GetClientId(kServiceId1, &client_id));
EXPECT_EQ(kClientId1, client_id);
service_id = 0;
client_id = 0;
EXPECT_FALSE(manager_.GetServiceId(kClientId2, &service_id));
EXPECT_FALSE(manager_.GetClientId(kServiceId2, &client_id));
EXPECT_EQ(0u, service_id);
EXPECT_EQ(0u, client_id);
EXPECT_TRUE(manager_.AddMapping(kClientId2, kServiceId2));
service_id = 0;
EXPECT_TRUE(manager_.GetServiceId(kClientId1, &service_id));
EXPECT_EQ(kServiceId1, service_id);
EXPECT_TRUE(manager_.GetServiceId(kClientId2, &service_id));
EXPECT_EQ(kServiceId2, service_id);
client_id = 0;
EXPECT_TRUE(manager_.GetClientId(kServiceId1, &client_id));
EXPECT_EQ(kClientId1, client_id);
EXPECT_TRUE(manager_.GetClientId(kServiceId2, &client_id));
EXPECT_EQ(kClientId2, client_id);
EXPECT_TRUE(manager_.RemoveMapping(kClientId1, kServiceId1));
EXPECT_FALSE(manager_.GetServiceId(kClientId1, &service_id));
EXPECT_FALSE(manager_.GetClientId(kServiceId1, &client_id));
EXPECT_FALSE(manager_.RemoveMapping(kClientId1, kServiceId1));
EXPECT_FALSE(manager_.RemoveMapping(kClientId2, kServiceId1));
EXPECT_FALSE(manager_.RemoveMapping(kClientId1, kServiceId2));
EXPECT_FALSE(manager_.AddMapping(kClientId2, kServiceId2));
EXPECT_FALSE(manager_.AddMapping(kClientId2, kServiceId1));
}
}
}