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

Side by Side Diff: cc/tiles/tile_manager_unittest.cc

Issue 1866043006: cc: Remove ScheduleOnOriginThread() and CompleteOnOriginThread(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip - fixed few unit tests Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 } 1828 }
1829 1829
1830 // Fake TileTaskRunner that just no-ops all calls. 1830 // Fake TileTaskRunner that just no-ops all calls.
1831 class FakeTileTaskRunner : public TileTaskRunner, public TileTaskClient { 1831 class FakeTileTaskRunner : public TileTaskRunner, public TileTaskClient {
1832 public: 1832 public:
1833 FakeTileTaskRunner() {} 1833 FakeTileTaskRunner() {}
1834 ~FakeTileTaskRunner() override {} 1834 ~FakeTileTaskRunner() override {}
1835 1835
1836 // TileTaskRunner methods. 1836 // TileTaskRunner methods.
1837 void Shutdown() override {} 1837 void Shutdown() override {}
1838 void CheckForCompletedTasks() override {} 1838 void CollectCompletedTasks(Task::Vector* completed_tasks) override {}
1839 ResourceFormat GetResourceFormat(bool must_support_alpha) const override { 1839 ResourceFormat GetResourceFormat(bool must_support_alpha) const override {
1840 return ResourceFormat::RGBA_8888; 1840 return ResourceFormat::RGBA_8888;
1841 } 1841 }
1842 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override { 1842 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override {
1843 return false; 1843 return false;
1844 } 1844 }
1845 1845
1846 TileTaskClient* AsTileTaskClient() override { return this; }
1847
1846 void ScheduleTasks(TaskGraph* graph) override {} 1848 void ScheduleTasks(TaskGraph* graph) override {}
1847 1849
1848 // TileTaskClient methods. 1850 // TileTaskClient methods.
1849 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( 1851 std::unique_ptr<RasterBuffer> AcquireBufferForRaster(
1850 const Resource* resource, 1852 const Resource* resource,
1851 uint64_t resource_content_id, 1853 uint64_t resource_content_id,
1852 uint64_t previous_content_id) override { 1854 uint64_t previous_content_id) override {
1853 NOTREACHED(); 1855 NOTREACHED();
1854 return nullptr; 1856 return nullptr;
1855 } 1857 }
1856 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override {} 1858 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override {}
1857 }; 1859 };
1858 1860
1859 // Fake TileTaskRunner that just cancels all scheduled tasks immediately. 1861 // Fake TileTaskRunner that just cancels all scheduled tasks immediately.
1860 class CancellingTileTaskRunner : public FakeTileTaskRunner { 1862 class CancellingTileTaskRunner : public FakeTileTaskRunner {
1861 public: 1863 public:
1862 CancellingTileTaskRunner() {} 1864 CancellingTileTaskRunner() {}
1863 ~CancellingTileTaskRunner() override {} 1865 ~CancellingTileTaskRunner() override {}
1864 1866
1865 void ScheduleTasks(TaskGraph* graph) override { 1867 void ScheduleTasks(TaskGraph* graph) override {
1866 // Just call CompleteOnOriginThread on each item in the queue. As none of 1868 // Don't do anything. As none of these items have scheduled yet, they will
1867 // these items have run yet, they will be treated as cancelled tasks. 1869 // be treated as cancelled tasks.
1868 for (const auto& node : graph->nodes) {
1869 static_cast<TileTask*>(node.task)->CompleteOnOriginThread(this);
1870 }
1871 } 1870 }
1872 }; 1871 };
1873 1872
1874 class PartialRasterTileManagerTest : public TileManagerTest { 1873 class PartialRasterTileManagerTest : public TileManagerTest {
1875 public: 1874 public:
1876 void CustomizeSettings(LayerTreeSettings* settings) override { 1875 void CustomizeSettings(LayerTreeSettings* settings) override {
1877 settings->use_partial_raster = true; 1876 settings->use_partial_raster = true;
1878 } 1877 }
1879 }; 1878 };
1880 1879
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 host_impl_ = nullptr; 1931 host_impl_ = nullptr;
1933 } 1932 }
1934 1933
1935 // Fake TileTaskRunner that verifies the resource content ID of raster tasks. 1934 // Fake TileTaskRunner that verifies the resource content ID of raster tasks.
1936 class VerifyResourceContentIdTileTaskRunner : public FakeTileTaskRunner { 1935 class VerifyResourceContentIdTileTaskRunner : public FakeTileTaskRunner {
1937 public: 1936 public:
1938 explicit VerifyResourceContentIdTileTaskRunner(uint64_t expected_resource_id) 1937 explicit VerifyResourceContentIdTileTaskRunner(uint64_t expected_resource_id)
1939 : expected_resource_id_(expected_resource_id) {} 1938 : expected_resource_id_(expected_resource_id) {}
1940 ~VerifyResourceContentIdTileTaskRunner() override {} 1939 ~VerifyResourceContentIdTileTaskRunner() override {}
1941 1940
1942 void ScheduleTasks(TaskGraph* graph) override { 1941 void ScheduleTasks(TaskGraph* graph) override {}
1943 for (const auto& node : graph->nodes) {
1944 TileTask* task = static_cast<TileTask*>(node.task);
1945 // Triggers a call to AcquireBufferForRaster.
1946 task->ScheduleOnOriginThread(this);
1947 // Calls TileManager as though task was cancelled.
1948 task->CompleteOnOriginThread(this);
1949 }
1950 }
1951 1942
1952 // TileTaskClient methods. 1943 // TileTaskClient methods.
1953 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( 1944 std::unique_ptr<RasterBuffer> AcquireBufferForRaster(
1954 const Resource* resource, 1945 const Resource* resource,
1955 uint64_t resource_content_id, 1946 uint64_t resource_content_id,
1956 uint64_t previous_content_id) override { 1947 uint64_t previous_content_id) override {
1957 EXPECT_EQ(expected_resource_id_, resource_content_id); 1948 EXPECT_EQ(expected_resource_id_, resource_content_id);
1958 return nullptr; 1949 return nullptr;
1959 } 1950 }
1960 1951
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 2020
2030 // Ensures that the tile manager does not attempt to reuse tiles when partial 2021 // Ensures that the tile manager does not attempt to reuse tiles when partial
2031 // raster is disabled. 2022 // raster is disabled.
2032 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { 2023 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) {
2033 RunPartialRasterCheck(std::move(host_impl_), 2024 RunPartialRasterCheck(std::move(host_impl_),
2034 false /* partial_raster_enabled */); 2025 false /* partial_raster_enabled */);
2035 } 2026 }
2036 2027
2037 } // namespace 2028 } // namespace
2038 } // namespace cc 2029 } // namespace cc
OLDNEW
« cc/raster/tile_task_worker_pool_unittest.cc ('K') | « cc/tiles/tile_manager_perftest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698