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

Unified Diff: cc/DecorationLayerChromiumTest.cpp

Issue 10963056: [cc] Add window decoration layers (NinePatch) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hacky rebase for Jerome to use 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/DecorationLayerChromium.cpp ('k') | cc/cc.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/DecorationLayerChromiumTest.cpp
diff --git a/cc/DecorationLayerChromiumTest.cpp b/cc/DecorationLayerChromiumTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fb737774f27cb60b55affdeab600e875cdba24cb
--- /dev/null
+++ b/cc/DecorationLayerChromiumTest.cpp
@@ -0,0 +1,140 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "DecorationLayerChromium.h"
+
+#include "CCLayerTreeHost.h"
+#include "CCOcclusionTracker.h"
+#include "CCOverdrawMetrics.h"
+#include "CCRenderingStats.h"
+#include "CCResourceProvider.h"
+#include "CCSingleThreadProxy.h"
+#include "CCTextureUpdateQueue.h"
+#include "FakeCCGraphicsContext.h"
+#include "FakeCCLayerTreeHostClient.h"
+#include "SkBitmap.h"
+#include "WebCompositorInitializer.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using namespace cc;
+using ::testing::Mock;
+using ::testing::_;
+using ::testing::AtLeast;
+using ::testing::AnyNumber;
+
+namespace {
+
+class MockCCLayerTreeHost : public CCLayerTreeHost {
+public:
+ MockCCLayerTreeHost()
+ : CCLayerTreeHost(&m_fakeClient, CCLayerTreeSettings())
+ {
+ initialize();
+ }
+
+private:
+ FakeCCLayerTreeHostClient m_fakeClient;
+};
+
+
+class DecorationLayerChromiumTest : public testing::Test {
+public:
+ DecorationLayerChromiumTest()
+ : m_compositorInitializer(0)
+ {
+ }
+
+protected:
+ virtual void SetUp()
+ {
+ m_layerTreeHost = adoptPtr(new MockCCLayerTreeHost);
+ }
+
+ virtual void TearDown()
+ {
+ Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
+
+ m_layerTreeHost->setRootLayer(0);
+ m_layerTreeHost.clear();
+ }
+
+ OwnPtr<MockCCLayerTreeHost> m_layerTreeHost;
+private:
+ WebKitTests::WebCompositorInitializer m_compositorInitializer;
+};
+
+TEST_F(DecorationLayerChromiumTest, triggerFullUploadOnceWhenChangingBitmap)
+{
+ scoped_refptr<DecorationLayerChromium> testLayer = DecorationLayerChromium::create();
+ ASSERT_TRUE(testLayer);
+ testLayer->setIsDrawable(true);
+ testLayer->setBounds(IntSize(100, 100));
+
+ m_layerTreeHost->setRootLayer(testLayer);
+ Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
+ EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get());
+
+ m_layerTreeHost->initializeRendererIfNeeded();
+
+ CCPriorityCalculator calculator;
+ CCTextureUpdateQueue queue;
+ CCOcclusionTracker occlusionTracker(IntRect(), false);
+ CCRenderingStats stats;
+
+ // No bitmap set should not trigger any uploads.
+ testLayer->setTexturePriorities(calculator);
+ testLayer->update(queue, &occlusionTracker, stats);
+ EXPECT_EQ(queue.fullUploadSize(), 0);
+ EXPECT_EQ(queue.partialUploadSize(), 0);
+
+ // Setting a bitmap set should trigger a single full upload.
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+ bitmap.allocPixels();
+ testLayer->setBitmap(bitmap, IntRect(5, 5, 1, 1));
+ testLayer->setTexturePriorities(calculator);
+ testLayer->update(queue, &occlusionTracker, stats);
+ EXPECT_EQ(queue.fullUploadSize(), 1);
+ EXPECT_EQ(queue.partialUploadSize(), 0);
+ TextureUploader::Parameters params = queue.takeFirstFullUpload();
+ EXPECT_TRUE(params.texture != NULL);
+
+ // Upload the texture.
+ m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 1024);
+ m_layerTreeHost->contentsTextureManager()->prioritizeTextures();
+
+ // Hack: Create a ResourceProvider here, because we cannot get to the one
+ // owned by the CCLayerTreeHostImpl.
+ CCProxy::setCurrentThreadIsImplThread(true);
+ CCProxy::setMainThreadBlocked(true);
+ scoped_ptr<CCGraphicsContext> context(WebKit::createFakeCCGraphicsContext());
+ OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(context.get()));
+ params.texture->texture()->acquireBackingTexture(resourceProvider.get());
+ ASSERT_TRUE(params.texture->texture()->haveBackingTexture());
+ CCProxy::setCurrentThreadIsImplThread(false);
+ CCProxy::setMainThreadBlocked(false);
+
+ // Nothing changed, so no repeated upload.
+ testLayer->setTexturePriorities(calculator);
+ testLayer->update(queue, &occlusionTracker, stats);
+ EXPECT_EQ(queue.fullUploadSize(), 0);
+ EXPECT_EQ(queue.partialUploadSize(), 0);
+
+ {
+ DebugScopedSetImplThread implThread;
+ DebugScopedSetMainThreadBlocked mainThreadBlocked;
+ m_layerTreeHost->contentsTextureManager()->clearAllMemory(resourceProvider.get());
+ }
+
+ // Reupload after eviction
+ testLayer->setTexturePriorities(calculator);
+ testLayer->update(queue, &occlusionTracker, stats);
+ EXPECT_EQ(queue.fullUploadSize(), 1);
+ EXPECT_EQ(queue.partialUploadSize(), 0);
+}
+
+} // anonymous namespace
« no previous file with comments | « cc/DecorationLayerChromium.cpp ('k') | cc/cc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698