OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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. |
| 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/run_loop.h" |
| 11 #include "cc/resources/sync_point_helper.h" |
| 12 #include "gpu/GLES2/gl2extchromium.h" |
| 13 |
| 14 namespace { |
| 15 |
| 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(); |
| 22 } |
| 23 |
| 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 cc::SyncPointHelper::SignalSyncPoint( |
| 28 context_.get(), sync_point, run_loop.QuitClosure()); |
| 29 run_loop.Run(); |
| 30 } |
| 31 |
| 32 // These tests should time out if the callback doesn't get called. |
| 33 void testSignalQuery(WebKit::WebGLId query) { |
| 34 base::RunLoop run_loop; |
| 35 cc::SyncPointHelper::SignalQuery( |
| 36 context_.get(), query, |
| 37 base::Bind(&RunOnlyOnce, run_loop.QuitClosure(), |
| 38 base::Owned(new int(0)))); |
| 39 run_loop.Run(); |
| 40 } |
| 41 }; |
| 42 |
| 43 CONTEXT_TEST_F(SignalTest, BasicSignalSyncPointTest) { |
| 44 testSignalSyncPoint(context_->insertSyncPoint()); |
| 45 }; |
| 46 |
| 47 CONTEXT_TEST_F(SignalTest, InvalidSignalSyncPointTest) { |
| 48 // Signalling something that doesn't exist should run the callback |
| 49 // immediately. |
| 50 testSignalSyncPoint(1297824234); |
| 51 }; |
| 52 |
| 53 CONTEXT_TEST_F(SignalTest, BasicSignalQueryTest) { |
| 54 unsigned query = context_->createQueryEXT(); |
| 55 context_->beginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query); |
| 56 context_->finish(); |
| 57 context_->endQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); |
| 58 testSignalQuery(query); |
| 59 context_->deleteQueryEXT(query); |
| 60 }; |
| 61 |
| 62 CONTEXT_TEST_F(SignalTest, SignalQueryUnboundTest) { |
| 63 WebKit::WebGLId query = context_->createQueryEXT(); |
| 64 testSignalQuery(query); |
| 65 context_->deleteQueryEXT(query); |
| 66 }; |
| 67 |
| 68 CONTEXT_TEST_F(SignalTest, InvalidSignalQueryUnboundTest) { |
| 69 // Signalling something that doesn't exist should run the callback |
| 70 // immediately. |
| 71 testSignalQuery(928729087); |
| 72 testSignalQuery(928729086); |
| 73 testSignalQuery(928729085); |
| 74 testSignalQuery(928729083); |
| 75 testSignalQuery(928729082); |
| 76 testSignalQuery(928729081); |
| 77 }; |
| 78 |
| 79 }; |
OLD | NEW |