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

Side by Side Diff: third_party/WebKit/Source/wtf/FunctionalTest.cpp

Issue 2327793002: Expose base::Callback::IsCancelled via WTF::Function (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/wtf/Functional.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 EXPECT_LE((*bound2)(CountCopy()), 2); // Compiler is allowed to optimize one copy away if the argument is rvalue. 582 EXPECT_LE((*bound2)(CountCopy()), 2); // Compiler is allowed to optimize one copy away if the argument is rvalue.
583 } 583 }
584 584
585 TEST(FunctionalTest, WeakPtr) 585 TEST(FunctionalTest, WeakPtr)
586 { 586 {
587 HasWeakPtrSupport obj; 587 HasWeakPtrSupport obj;
588 int counter = 0; 588 int counter = 0;
589 std::unique_ptr<WTF::Closure> bound = WTF::bind(&HasWeakPtrSupport::incremen t, obj.createWeakPtr(), WTF::unretained(&counter)); 589 std::unique_ptr<WTF::Closure> bound = WTF::bind(&HasWeakPtrSupport::incremen t, obj.createWeakPtr(), WTF::unretained(&counter));
590 590
591 (*bound)(); 591 (*bound)();
592 EXPECT_FALSE(bound->isCancelled());
592 EXPECT_EQ(1, counter); 593 EXPECT_EQ(1, counter);
593 594
594 obj.revokeAll(); 595 obj.revokeAll();
596 EXPECT_TRUE(bound->isCancelled());
595 (*bound)(); 597 (*bound)();
596 EXPECT_EQ(1, counter); 598 EXPECT_EQ(1, counter);
597 } 599 }
598 600
599 } // anonymous namespace 601 } // anonymous namespace
600 602
601 } // namespace WTF 603 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Functional.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698