OLD | NEW |
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 Loading... |
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 |
OLD | NEW |