Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1696)

Side by Side Diff: cc/ThrottledTextureUploaderTest.cpp

Issue 11108020: [cc] Change cc_tests.gyp filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/TextureLayerChromiumTest.cpp ('k') | cc/TiledLayerChromiumTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include <wtf/RefPtr.h>
16
17 using namespace cc;
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 class FakeTexture : public cc::LayerTextureUpdater::Texture {
47 public:
48 FakeTexture() : LayerTextureUpdater::Texture(
49 CCPrioritizedTexture::create(NULL, IntSize(256,256), GL_RGBA)) {
50 }
51
52 virtual void updateRect(cc::CCResourceProvider* , const cc::IntRect&, const cc ::IntSize&) OVERRIDE { }
53
54 };
55
56
57 TEST(ThrottledTextureUploaderTest, NumBlockingUploads)
58 {
59 OwnPtr<FakeWebGraphicsContext3DWithQueryTesting> fakeContext(adoptPtr(new Fa keWebGraphicsContext3DWithQueryTesting));
60 OwnPtr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::create (fakeContext.get());
61 OwnPtr<FakeTexture> texture = adoptPtr(new FakeTexture);
62 TextureUploader::Parameters upload;
63 upload.texture = texture.get();
64 upload.sourceRect = IntRect(IntPoint(0,0), texture->texture()->size());
65 upload.destOffset = IntSize();
66
67 fakeContext->setResultAvailable(0);
68 EXPECT_EQ(0, uploader->numBlockingUploads());
69 uploader->uploadTexture(NULL, upload);
70 EXPECT_EQ(1, uploader->numBlockingUploads());
71 uploader->uploadTexture(NULL, upload);
72 EXPECT_EQ(2, uploader->numBlockingUploads());
73
74 fakeContext->setResultAvailable(1);
75 EXPECT_EQ(0, uploader->numBlockingUploads());
76 uploader->uploadTexture(NULL, upload);
77 EXPECT_EQ(0, uploader->numBlockingUploads());
78 uploader->uploadTexture(NULL, upload);
79 uploader->uploadTexture(NULL, upload);
80 EXPECT_EQ(0, uploader->numBlockingUploads());
81 }
82
83 TEST(ThrottledTextureUploaderTest, MarkPendingUploadsAsNonBlocking)
84 {
85 OwnPtr<FakeWebGraphicsContext3DWithQueryTesting> fakeContext(adoptPtr(new Fa keWebGraphicsContext3DWithQueryTesting));
86 OwnPtr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::create (fakeContext.get());
87 OwnPtr<FakeTexture> texture = adoptPtr(new FakeTexture);
88 TextureUploader::Parameters upload;
89 upload.texture = texture.get();
90 upload.sourceRect = IntRect(IntPoint(0,0), texture->texture()->size());
91 upload.destOffset = IntSize();
92
93 fakeContext->setResultAvailable(0);
94 EXPECT_EQ(0, uploader->numBlockingUploads());
95 uploader->uploadTexture(NULL, upload);
96 uploader->uploadTexture(NULL, upload);
97 EXPECT_EQ(2, uploader->numBlockingUploads());
98
99 uploader->markPendingUploadsAsNonBlocking();
100 EXPECT_EQ(0, uploader->numBlockingUploads());
101 uploader->uploadTexture(NULL, upload);
102 EXPECT_EQ(1, uploader->numBlockingUploads());
103
104 fakeContext->setResultAvailable(1);
105 EXPECT_EQ(0, uploader->numBlockingUploads());
106 uploader->uploadTexture(NULL, upload);
107 uploader->markPendingUploadsAsNonBlocking();
108 EXPECT_EQ(0, uploader->numBlockingUploads());
109 }
110
111 } // namespace
OLDNEW
« no previous file with comments | « cc/TextureLayerChromiumTest.cpp ('k') | cc/TiledLayerChromiumTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698