1 // Copyright 2014 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.
6 #include <GLES2/gl2ext.h>
7 #include <GLES2/gl2extchromium.h>
9 #include "base/logging.h"
10 #include "gpu/command_buffer/service/feature_info.h"
11 #include "gpu/command_buffer/tests/gl_manager.h"
12 #include "gpu/command_buffer/tests/gl_test_utils.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
18 class GLLoseContextTest
: public testing::Test
{
20 virtual void SetUp() {
21 GLManager::Options options
;
22 gl2_
.Initialize(options
);
23 options
.context_lost_allowed
= true;
24 gl1a_
.Initialize(options
);
25 options
.share_group_manager
= &gl1a_
;
26 gl1b_
.Initialize(options
);
29 virtual void TearDown() {
40 // Test that glLoseContextCHROMIUM loses context in the same
41 // share group but not other.
42 TEST_F(GLLoseContextTest
, ShareGroup
) {
43 // If losing the context will cause the process to exit, do not perform this
44 // test as it will cause all subsequent tests to not run.
45 if (gl1a_
.workarounds().exit_on_context_lost
)
49 glLoseContextCHROMIUM(
50 GL_GUILTY_CONTEXT_RESET_EXT
, GL_INNOCENT_CONTEXT_RESET_EXT
);
52 uint8 expected_no_draw
[] = {
53 GLTestHelper::kCheckClearValue
,
54 GLTestHelper::kCheckClearValue
,
55 GLTestHelper::kCheckClearValue
,
56 GLTestHelper::kCheckClearValue
,
58 // Expect the read will fail.
59 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_no_draw
));
61 // Expect the read will fail.
62 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_no_draw
));
64 uint8 expected_draw
[] = { 0, 0, 0, 0, };
65 // Expect the read will succeed.
66 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_draw
));