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

Side by Side Diff: cc/trees/layer_tree_impl_unittest.cc

Issue 2580493002: Splitting DidSwap in cc::SwapPromise into WillSwap and DidSwap (Closed)
Patch Set: x Created 4 years 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
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/swap_promise_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/trees/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "cc/layers/heads_up_display_layer_impl.h" 8 #include "cc/layers/heads_up_display_layer_impl.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 namespace { 2306 namespace {
2307 2307
2308 class PersistentSwapPromise 2308 class PersistentSwapPromise
2309 : public SwapPromise, 2309 : public SwapPromise,
2310 public base::SupportsWeakPtr<PersistentSwapPromise> { 2310 public base::SupportsWeakPtr<PersistentSwapPromise> {
2311 public: 2311 public:
2312 PersistentSwapPromise() = default; 2312 PersistentSwapPromise() = default;
2313 ~PersistentSwapPromise() override = default; 2313 ~PersistentSwapPromise() override = default;
2314 2314
2315 void DidActivate() override {} 2315 void DidActivate() override {}
2316 MOCK_METHOD1(DidSwap, void(CompositorFrameMetadata* metadata)); 2316 MOCK_METHOD1(WillSwap, void(CompositorFrameMetadata* metadata));
2317 MOCK_METHOD0(DidSwap, void());
2317 2318
2318 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { 2319 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override {
2319 return DidNotSwapAction::KEEP_ACTIVE; 2320 return DidNotSwapAction::KEEP_ACTIVE;
2320 } 2321 }
2321 2322
2322 void OnCommit() override {} 2323 void OnCommit() override {}
2323 int64_t TraceId() const override { return 0; } 2324 int64_t TraceId() const override { return 0; }
2324 }; 2325 };
2325 2326
2326 class NotPersistentSwapPromise 2327 class NotPersistentSwapPromise
2327 : public SwapPromise, 2328 : public SwapPromise,
2328 public base::SupportsWeakPtr<NotPersistentSwapPromise> { 2329 public base::SupportsWeakPtr<NotPersistentSwapPromise> {
2329 public: 2330 public:
2330 NotPersistentSwapPromise() = default; 2331 NotPersistentSwapPromise() = default;
2331 ~NotPersistentSwapPromise() override = default; 2332 ~NotPersistentSwapPromise() override = default;
2332 2333
2333 void DidActivate() override {} 2334 void DidActivate() override {}
2334 void DidSwap(CompositorFrameMetadata* metadata) override {} 2335 void WillSwap(CompositorFrameMetadata* metadata) override {}
2336 void DidSwap() override {}
2335 2337
2336 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { 2338 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override {
2337 return DidNotSwapAction::BREAK_PROMISE; 2339 return DidNotSwapAction::BREAK_PROMISE;
2338 } 2340 }
2339 2341
2340 void OnCommit() override {} 2342 void OnCommit() override {}
2341 int64_t TraceId() const override { return 0; } 2343 int64_t TraceId() const override { return 0; }
2342 }; 2344 };
2343 2345
2344 } // namespace 2346 } // namespace
(...skipping 16 matching lines...) Expand all
2361 2363
2362 std::vector<std::unique_ptr<SwapPromise>> promises; 2364 std::vector<std::unique_ptr<SwapPromise>> promises;
2363 host_impl().active_tree()->PassSwapPromises(std::move(promises)); 2365 host_impl().active_tree()->PassSwapPromises(std::move(promises));
2364 host_impl().active_tree()->BreakSwapPromises( 2366 host_impl().active_tree()->BreakSwapPromises(
2365 SwapPromise::DidNotSwapReason::SWAP_FAILS); 2367 SwapPromise::DidNotSwapReason::SWAP_FAILS);
2366 2368
2367 ASSERT_EQ(promises_count, persistent_promises.size()); 2369 ASSERT_EQ(promises_count, persistent_promises.size());
2368 for (size_t i = 0; i < persistent_promises.size(); ++i) { 2370 for (size_t i = 0; i < persistent_promises.size(); ++i) {
2369 SCOPED_TRACE(testing::Message() << "While checking case #" << i); 2371 SCOPED_TRACE(testing::Message() << "While checking case #" << i);
2370 ASSERT_TRUE(persistent_promises[i]); 2372 ASSERT_TRUE(persistent_promises[i]);
2371 EXPECT_CALL(*persistent_promises[i], DidSwap(testing::_)); 2373 EXPECT_CALL(*persistent_promises[i], WillSwap(testing::_));
2372 } 2374 }
2373 host_impl().active_tree()->FinishSwapPromises(nullptr); 2375 host_impl().active_tree()->FinishSwapPromises(nullptr);
2374 } 2376 }
2375 2377
2376 TEST_F(LayerTreeImplTest, NotPersistentSwapPromisesAreDroppedWhenSwapFails) { 2378 TEST_F(LayerTreeImplTest, NotPersistentSwapPromisesAreDroppedWhenSwapFails) {
2377 const size_t promises_count = 2; 2379 const size_t promises_count = 2;
2378 2380
2379 std::vector<base::WeakPtr<NotPersistentSwapPromise>> not_persistent_promises; 2381 std::vector<base::WeakPtr<NotPersistentSwapPromise>> not_persistent_promises;
2380 std::vector<std::unique_ptr<NotPersistentSwapPromise>> 2382 std::vector<std::unique_ptr<NotPersistentSwapPromise>>
2381 not_persistent_promises_to_pass; 2383 not_persistent_promises_to_pass;
(...skipping 22 matching lines...) Expand all
2404 auto weak_promise = promise->AsWeakPtr(); 2406 auto weak_promise = promise->AsWeakPtr();
2405 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); 2407 host_impl().active_tree()->QueueSwapPromise(std::move(promise));
2406 host_impl().active_tree()->BreakSwapPromises( 2408 host_impl().active_tree()->BreakSwapPromises(
2407 SwapPromise::DidNotSwapReason::SWAP_FAILS); 2409 SwapPromise::DidNotSwapReason::SWAP_FAILS);
2408 EXPECT_FALSE(weak_promise); 2410 EXPECT_FALSE(weak_promise);
2409 } 2411 }
2410 } 2412 }
2411 2413
2412 } // namespace 2414 } // namespace
2413 } // namespace cc 2415 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/swap_promise_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698