OLD | NEW |
| (Empty) |
1 // Copyright 2012 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 #include "config.h" | |
6 | |
7 #include "ThrottledTextureUploader.h" | |
8 | |
9 #include "Extensions3DChromium.h" | |
10 #include "FakeWebGraphicsContext3D.h" | |
11 #include "GraphicsContext3D.h" | |
12 | |
13 #include <gmock/gmock.h> | |
14 #include <gtest/gtest.h> | |
15 #include <wtf/RefPtr.h> | |
16 | |
17 using namespace WebCore; | |
18 using namespace WebKit; | |
19 | |
20 namespace { | |
21 | |
22 class FakeWebGraphicsContext3DWithQueryTesting : public FakeWebGraphicsContext3D
{ | |
23 public: | |
24 FakeWebGraphicsContext3DWithQueryTesting() : m_resultAvailable(0) | |
25 { | |
26 } | |
27 | |
28 virtual void getQueryObjectuivEXT(WebGLId, GC3Denum type, GC3Duint* value) | |
29 { | |
30 switch (type) { | |
31 case Extensions3DChromium::QUERY_RESULT_AVAILABLE_EXT: | |
32 *value = m_resultAvailable; | |
33 break; | |
34 default: | |
35 *value = 0; | |
36 break; | |
37 } | |
38 } | |
39 | |
40 void setResultAvailable(unsigned resultAvailable) { m_resultAvailable = resu
ltAvailable; } | |
41 | |
42 private: | |
43 unsigned m_resultAvailable; | |
44 }; | |
45 | |
46 TEST(ThrottledTextureUploaderTest, IsBusy) | |
47 { | |
48 OwnPtr<FakeWebGraphicsContext3DWithQueryTesting> fakeContext(adoptPtr(new Fa
keWebGraphicsContext3DWithQueryTesting)); | |
49 OwnPtr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::create
(fakeContext.get(), 2); | |
50 | |
51 fakeContext->setResultAvailable(0); | |
52 EXPECT_FALSE(uploader->isBusy()); | |
53 uploader->beginUploads(); | |
54 uploader->endUploads(); | |
55 EXPECT_FALSE(uploader->isBusy()); | |
56 uploader->beginUploads(); | |
57 uploader->endUploads(); | |
58 EXPECT_TRUE(uploader->isBusy()); | |
59 | |
60 fakeContext->setResultAvailable(1); | |
61 EXPECT_FALSE(uploader->isBusy()); | |
62 uploader->beginUploads(); | |
63 uploader->endUploads(); | |
64 EXPECT_FALSE(uploader->isBusy()); | |
65 uploader->beginUploads(); | |
66 uploader->endUploads(); | |
67 EXPECT_FALSE(uploader->isBusy()); | |
68 uploader->beginUploads(); | |
69 uploader->endUploads(); | |
70 } | |
71 | |
72 } // namespace | |
OLD | NEW |