| Index: content/common/gpu/gpu_channel_manager_unittest.cc
|
| diff --git a/content/common/gpu/gpu_channel_manager_unittest.cc b/content/common/gpu/gpu_channel_manager_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fb2dcba3de1cf7fdbdbee8bed04a183d2dda189f
|
| --- /dev/null
|
| +++ b/content/common/gpu/gpu_channel_manager_unittest.cc
|
| @@ -0,0 +1,86 @@
|
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/test/test_simple_task_runner.h"
|
| +#include "content/common/gpu/gpu_channel.h"
|
| +#include "content/common/gpu/gpu_channel_manager.h"
|
| +#include "content/common/gpu/gpu_messages.h"
|
| +#include "content/common/message_router.h"
|
| +#include "gpu/command_buffer/common/value_state.h"
|
| +#include "gpu/command_buffer/service/gl_utils.h"
|
| +#include "gpu/command_buffer/service/valuebuffer_manager.h"
|
| +#include "ipc/ipc_sync_channel.h"
|
| +
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +using gpu::gles2::ValuebufferManager;
|
| +using gpu::ValueState;
|
| +
|
| +namespace content {
|
| +
|
| +class GpuChannelManagerTest : public testing::Test {
|
| + public:
|
| + GpuChannelManagerTest() {}
|
| +
|
| + void SetUp() override {
|
| + task_runner_ = scoped_refptr<base::SingleThreadTaskRunner>(
|
| + new base::TestSimpleTaskRunner());
|
| + channel_ = IPC::SyncChannel::Create(
|
| + &router_, task_runner_, NULL);
|
| + manager_.reset(
|
| + new GpuChannelManager(&router_,
|
| + NULL,
|
| + base::MessageLoopProxy::current().get(),
|
| + NULL,
|
| + channel_.get()));
|
| + }
|
| +
|
| + protected:
|
| + scoped_ptr<GpuChannelManager> manager_;
|
| +
|
| + private:
|
| + base::MessageLoop message_loop_;
|
| +
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| + scoped_ptr<IPC::SyncChannel> channel_;
|
| + MessageRouter router_;
|
| +};
|
| +
|
| +TEST_F(GpuChannelManagerTest, SecureValueStateForwarding) {
|
| + const int kClientId1 = 111;
|
| + const int kClientId2 = 222;
|
| + ValueState kValueState1;
|
| + kValueState1.int_value[0] = 1111;
|
| + ValueState kValueState2;
|
| + kValueState2.int_value[0] = 3333;
|
| +
|
| + // Initialize gpu channels
|
| + manager_->OnMessageReceived(
|
| + GpuMsg_EstablishChannel(kClientId1, false, false));
|
| + GpuChannel *channel1 = manager_->LookupChannel(kClientId1);
|
| + manager_->OnMessageReceived(
|
| + GpuMsg_EstablishChannel(kClientId2, false, false));
|
| + GpuChannel *channel2 = manager_->LookupChannel(kClientId2);
|
| + ASSERT_TRUE(channel1 != NULL);
|
| + ASSERT_TRUE(channel2 != NULL);
|
| + ASSERT_NE(channel1, channel2);
|
| +
|
| + // Make sure value states are only accessible by proper channels
|
| + manager_->OnMessageReceived(GpuMsg_UpdateValueState(
|
| + kClientId1, GL_MOUSE_POSITION_CHROMIUM, kValueState1));
|
| + manager_->OnMessageReceived(GpuMsg_UpdateValueState(
|
| + kClientId2, GL_MOUSE_POSITION_CHROMIUM, kValueState2));
|
| +
|
| + const ValueState* stubValueState1 =
|
| + channel1->valuebuffer_manager()->GetPendingState(
|
| + GL_MOUSE_POSITION_CHROMIUM);
|
| + const ValueState* stubValueState2 =
|
| + channel2->valuebuffer_manager()->GetPendingState(
|
| + GL_MOUSE_POSITION_CHROMIUM);
|
| + ASSERT_EQ(stubValueState1->int_value[0], kValueState1.int_value[0]);
|
| + ASSERT_EQ(stubValueState2->int_value[0], kValueState2.int_value[0]);
|
| + ASSERT_NE(stubValueState1->int_value[0], stubValueState2->int_value[0]);
|
| +}
|
| +
|
| +} // namespace content
|
|
|