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

Unified Diff: cc/nine_patch_layer_unittest.cc

Issue 12603013: Part 10 of cc/ directory shuffles: layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/nine_patch_layer_impl_unittest.cc ('k') | cc/output/gl_renderer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/nine_patch_layer_unittest.cc
diff --git a/cc/nine_patch_layer_unittest.cc b/cc/nine_patch_layer_unittest.cc
deleted file mode 100644
index 50e83e6a957a04af2715fb8dc38d33893e60d8e4..0000000000000000000000000000000000000000
--- a/cc/nine_patch_layer_unittest.cc
+++ /dev/null
@@ -1,148 +0,0 @@
-// 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 "cc/nine_patch_layer.h"
-
-#include "cc/debug/overdraw_metrics.h"
-#include "cc/resources/prioritized_resource_manager.h"
-#include "cc/resources/resource_provider.h"
-#include "cc/resources/resource_update_queue.h"
-#include "cc/scheduler/texture_uploader.h"
-#include "cc/test/fake_layer_tree_host_client.h"
-#include "cc/test/fake_output_surface.h"
-#include "cc/test/geometry_test_utils.h"
-#include "cc/test/layer_tree_test_common.h"
-#include "cc/trees/layer_tree_host.h"
-#include "cc/trees/occlusion_tracker.h"
-#include "cc/trees/single_thread_proxy.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-using ::testing::Mock;
-using ::testing::_;
-using ::testing::AtLeast;
-using ::testing::AnyNumber;
-
-namespace cc {
-namespace {
-
-class MockLayerTreeHost : public LayerTreeHost {
-public:
- MockLayerTreeHost()
- : LayerTreeHost(&m_fakeClient, LayerTreeSettings())
- {
- Initialize(scoped_ptr<Thread>(NULL));
- }
-
-private:
- FakeLayerImplTreeHostClient m_fakeClient;
-};
-
-
-class NinePatchLayerTest : public testing::Test {
-public:
- NinePatchLayerTest()
- {
- }
-
- Proxy* proxy() const { return layer_tree_host_->proxy(); }
-
-protected:
- virtual void SetUp()
- {
- layer_tree_host_.reset(new MockLayerTreeHost);
- }
-
- virtual void TearDown()
- {
- Mock::VerifyAndClearExpectations(layer_tree_host_.get());
- }
-
- scoped_ptr<MockLayerTreeHost> layer_tree_host_;
-};
-
-TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap)
-{
- scoped_refptr<NinePatchLayer> testLayer = NinePatchLayer::Create();
- ASSERT_TRUE(testLayer);
- testLayer->SetIsDrawable(true);
- testLayer->SetBounds(gfx::Size(100, 100));
-
- layer_tree_host_->SetRootLayer(testLayer);
- Mock::VerifyAndClearExpectations(layer_tree_host_.get());
- EXPECT_EQ(testLayer->layer_tree_host(), layer_tree_host_.get());
-
- layer_tree_host_->InitializeRendererIfNeeded();
-
- PriorityCalculator calculator;
- ResourceUpdateQueue queue;
- OcclusionTracker occlusionTracker(gfx::Rect(), false);
-
- // No bitmap set should not trigger any uploads.
- testLayer->SetTexturePriorities(calculator);
- testLayer->Update(&queue, &occlusionTracker, NULL);
- 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, gfx::Rect(5, 5, 1, 1));
- testLayer->SetTexturePriorities(calculator);
- testLayer->Update(&queue, &occlusionTracker, NULL);
- EXPECT_EQ(queue.fullUploadSize(), 1);
- EXPECT_EQ(queue.partialUploadSize(), 0);
- ResourceUpdate params = queue.takeFirstFullUpload();
- EXPECT_TRUE(params.texture != NULL);
-
- // Upload the texture.
- layer_tree_host_->contents_texture_manager()->setMaxMemoryLimitBytes(1024 * 1024);
- layer_tree_host_->contents_texture_manager()->prioritizeTextures();
-
- scoped_ptr<OutputSurface> outputSurface;
- scoped_ptr<ResourceProvider> resourceProvider;
- {
- DebugScopedSetImplThread implThread(proxy());
- DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy());
- outputSurface = createFakeOutputSurface();
- resourceProvider = ResourceProvider::Create(outputSurface.get());
- params.texture->acquireBackingTexture(resourceProvider.get());
- ASSERT_TRUE(params.texture->haveBackingTexture());
- }
-
- // Nothing changed, so no repeated upload.
- testLayer->SetTexturePriorities(calculator);
- testLayer->Update(&queue, &occlusionTracker, NULL);
- EXPECT_EQ(queue.fullUploadSize(), 0);
- EXPECT_EQ(queue.partialUploadSize(), 0);
-
- {
- DebugScopedSetImplThread implThread(proxy());
- DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy());
- layer_tree_host_->contents_texture_manager()->clearAllMemory(resourceProvider.get());
- }
-
- // Reupload after eviction
- testLayer->SetTexturePriorities(calculator);
- testLayer->Update(&queue, &occlusionTracker, NULL);
- EXPECT_EQ(queue.fullUploadSize(), 1);
- EXPECT_EQ(queue.partialUploadSize(), 0);
-
- // PrioritizedResourceManager clearing
- layer_tree_host_->contents_texture_manager()->unregisterTexture(params.texture);
- EXPECT_EQ(NULL, params.texture->resourceManager());
- testLayer->SetTexturePriorities(calculator);
- ResourceUpdateQueue queue2;
- testLayer->Update(&queue2, &occlusionTracker, NULL);
- EXPECT_EQ(queue2.fullUploadSize(), 1);
- EXPECT_EQ(queue2.partialUploadSize(), 0);
- params = queue2.takeFirstFullUpload();
- EXPECT_TRUE(params.texture != NULL);
- EXPECT_EQ(params.texture->resourceManager(), layer_tree_host_->contents_texture_manager());
-}
-
-} // namespace
-} // namespace cc
« no previous file with comments | « cc/nine_patch_layer_impl_unittest.cc ('k') | cc/output/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698