OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/dom/custom/CustomElementReactionQueue.h" | 5 #include "core/dom/custom/CustomElementReactionQueue.h" |
6 | 6 |
| 7 #include <initializer_list> |
| 8 #include <vector> |
7 #include "core/dom/custom/CustomElementReaction.h" | 9 #include "core/dom/custom/CustomElementReaction.h" |
8 #include "core/dom/custom/CustomElementReactionTestHelpers.h" | 10 #include "core/dom/custom/CustomElementReactionTestHelpers.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "wtf/Functional.h" | 12 #include "wtf/Functional.h" |
11 #include <initializer_list> | |
12 #include <vector> | |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 TEST(CustomElementReactionQueueTest, invokeReactions_one) { | 16 TEST(CustomElementReactionQueueTest, invokeReactions_one) { |
17 std::vector<char> log; | 17 std::vector<char> log; |
18 CustomElementReactionQueue* queue = new CustomElementReactionQueue(); | 18 CustomElementReactionQueue* queue = new CustomElementReactionQueue(); |
19 queue->add(new TestReaction({new Log('a', log)})); | 19 queue->add(new TestReaction({new Log('a', log)})); |
20 queue->invokeReactions(nullptr); | 20 queue->invokeReactions(nullptr); |
21 EXPECT_EQ(log, std::vector<char>({'a'})) | 21 EXPECT_EQ(log, std::vector<char>({'a'})) |
22 << "the reaction should have been invoked"; | 22 << "the reaction should have been invoked"; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 [](CustomElementReactionQueue* queue, Element*) { queue->clear(); }, | 63 [](CustomElementReactionQueue* queue, Element*) { queue->clear(); }, |
64 wrapPersistent(queue)))})); | 64 wrapPersistent(queue)))})); |
65 queue->add(new TestReaction({new Log('b', log)})); | 65 queue->add(new TestReaction({new Log('b', log)})); |
66 | 66 |
67 queue->invokeReactions(nullptr); | 67 queue->invokeReactions(nullptr); |
68 EXPECT_EQ(log, std::vector<char>({'a'})) | 68 EXPECT_EQ(log, std::vector<char>({'a'})) |
69 << "only 'a' should be logged; the second log should have been cleared"; | 69 << "only 'a' should be logged; the second log should have been cleared"; |
70 } | 70 } |
71 | 71 |
72 } // namespace blink | 72 } // namespace blink |
OLD | NEW |