| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 EXPECT_EQ(2, five->RefCount()); | 358 EXPECT_EQ(2, five->RefCount()); |
| 359 EXPECT_EQ(10, (*multiply_five_by_two_function)()); | 359 EXPECT_EQ(10, (*multiply_five_by_two_function)()); |
| 360 EXPECT_EQ(2, five->RefCount()); | 360 EXPECT_EQ(2, five->RefCount()); |
| 361 | 361 |
| 362 std::unique_ptr<Function<int()>> multiply_four_by_two_function = | 362 std::unique_ptr<Function<int()>> multiply_four_by_two_function = |
| 363 Bind(MultiplyNumberByTwo, Number::Create(4)); | 363 Bind(MultiplyNumberByTwo, Number::Create(4)); |
| 364 EXPECT_EQ(8, (*multiply_four_by_two_function)()); | 364 EXPECT_EQ(8, (*multiply_four_by_two_function)()); |
| 365 | 365 |
| 366 RefPtr<Number> six = Number::Create(6); | 366 RefPtr<Number> six = Number::Create(6); |
| 367 std::unique_ptr<Function<int()>> multiply_six_by_two_function = | 367 std::unique_ptr<Function<int()>> multiply_six_by_two_function = |
| 368 Bind(MultiplyNumberByTwo, six.Release()); | 368 Bind(MultiplyNumberByTwo, std::move(six)); |
| 369 EXPECT_FALSE(six); | 369 EXPECT_FALSE(six); |
| 370 EXPECT_EQ(12, (*multiply_six_by_two_function)()); | 370 EXPECT_EQ(12, (*multiply_six_by_two_function)()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 TEST(FunctionalTest, UnretainedWithRefCounted) { | 373 TEST(FunctionalTest, UnretainedWithRefCounted) { |
| 374 RefPtr<Number> five = Number::Create(5); | 374 RefPtr<Number> five = Number::Create(5); |
| 375 EXPECT_EQ(1, five->RefCount()); | 375 EXPECT_EQ(1, five->RefCount()); |
| 376 std::unique_ptr<Function<int()>> multiply_five_by_two_function = | 376 std::unique_ptr<Function<int()>> multiply_five_by_two_function = |
| 377 Bind(MultiplyNumberByTwo, WTF::Unretained(five.Get())); | 377 Bind(MultiplyNumberByTwo, WTF::Unretained(five.Get())); |
| 378 EXPECT_EQ(1, five->RefCount()); | 378 EXPECT_EQ(1, five->RefCount()); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 586 |
| 587 obj.RevokeAll(); | 587 obj.RevokeAll(); |
| 588 EXPECT_TRUE(bound->IsCancelled()); | 588 EXPECT_TRUE(bound->IsCancelled()); |
| 589 (*bound)(); | 589 (*bound)(); |
| 590 EXPECT_EQ(1, counter); | 590 EXPECT_EQ(1, counter); |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // anonymous namespace | 593 } // anonymous namespace |
| 594 | 594 |
| 595 } // namespace WTF | 595 } // namespace WTF |
| OLD | NEW |