#include "gpu/command_buffer/common/shm_count.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gpu {
TEST(ShmCountTest, BasicUsage) {
GpuProcessHostShmCount host_count;
EXPECT_EQ(host_count.GetCount(), 0);
GpuProcessShmCount service_count(host_count.CloneRegion());
{
GpuProcessShmCount::ScopedIncrement scoped_increment(&service_count);
EXPECT_EQ(host_count.GetCount(), 1);
{
GpuProcessShmCount::ScopedIncrement scoped_increment2(&service_count);
EXPECT_EQ(host_count.GetCount(), 2);
}
EXPECT_EQ(host_count.GetCount(), 1);
}
EXPECT_EQ(host_count.GetCount(), 0);
}
TEST(ShmCountTest, NotInitialized) {
GpuProcessShmCount service_count{base::UnsafeSharedMemoryRegion()};
{ GpuProcessShmCount::ScopedIncrement scoped_increment(&service_count); }
}
}