[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / common / gpu / client / gpu_context_tests.h
blob5b8fb4970bef48bae95fcc533ffa2153c40a0731
1 // Copyright 2013 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 // These tests are run twice:
6 // Once in a gpu test with an in-process WebGraphicsContext3D.
7 // Once in a browsertest with a gpu-process WebGraphicsContext3D.
9 #include "base/bind.h"
10 #include "base/run_loop.h"
11 #include "gpu/GLES2/gl2extchromium.h"
12 #include "gpu/command_buffer/client/context_support.h"
14 namespace {
16 class SignalTest : public ContextTestBase {
17 public:
18 static void RunOnlyOnce(base::Closure cb, int* tmp) {
19 CHECK_EQ(*tmp, 0);
20 ++*tmp;
21 cb.Run();
24 // These tests should time out if the callback doesn't get called.
25 void TestSignalSyncPoint(unsigned sync_point) {
26 base::RunLoop run_loop;
27 context_support_->SignalSyncPoint(sync_point, run_loop.QuitClosure());
28 run_loop.Run();
31 // These tests should time out if the callback doesn't get called.
32 void TestSignalQuery(blink::WebGLId query) {
33 base::RunLoop run_loop;
34 context_support_->SignalQuery(
35 query,
36 base::Bind(
37 &RunOnlyOnce, run_loop.QuitClosure(), base::Owned(new int(0))));
38 run_loop.Run();
42 CONTEXT_TEST_F(SignalTest, BasicSignalSyncPointTest) {
43 if (!context_)
44 return;
46 TestSignalSyncPoint(context_->insertSyncPoint());
49 CONTEXT_TEST_F(SignalTest, InvalidSignalSyncPointTest) {
50 if (!context_)
51 return;
53 // Signalling something that doesn't exist should run the callback
54 // immediately.
55 TestSignalSyncPoint(1297824234);
58 CONTEXT_TEST_F(SignalTest, BasicSignalQueryTest) {
59 if (!context_)
60 return;
62 unsigned query = context_->createQueryEXT();
63 context_->beginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query);
64 context_->finish();
65 context_->endQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
66 TestSignalQuery(query);
67 context_->deleteQueryEXT(query);
70 CONTEXT_TEST_F(SignalTest, SignalQueryUnboundTest) {
71 if (!context_)
72 return;
74 blink::WebGLId query = context_->createQueryEXT();
75 TestSignalQuery(query);
76 context_->deleteQueryEXT(query);
79 CONTEXT_TEST_F(SignalTest, InvalidSignalQueryUnboundTest) {
80 if (!context_)
81 return;
83 // Signalling something that doesn't exist should run the callback
84 // immediately.
85 TestSignalQuery(928729087);
86 TestSignalQuery(928729086);
87 TestSignalQuery(928729085);
88 TestSignalQuery(928729083);
89 TestSignalQuery(928729082);
90 TestSignalQuery(928729081);