| 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/page/EventSourceParser.h" | 5 #include "core/page/EventSourceParser.h" |
| 6 | 6 |
| 7 #include "core/page/EventSource.h" | 7 #include "core/page/EventSource.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "wtf/text/CharacterNames.h" | 9 #include "wtf/text/CharacterNames.h" |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 void onReconnectionTimeSet(unsigned long long reconnectionTime) override | 53 void onReconnectionTimeSet(unsigned long long reconnectionTime) override |
| 54 { | 54 { |
| 55 m_events.append(EventOrReconnectionTimeSetting(reconnectionTime)); | 55 m_events.append(EventOrReconnectionTimeSetting(reconnectionTime)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 Vector<EventOrReconnectionTimeSetting> m_events; | 59 Vector<EventOrReconnectionTimeSetting> m_events; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class StoppingClient : public GarbageCollectedFinalized<Client>, public EventSou
rceParser::Client { | 62 class StoppingClient : public GarbageCollectedFinalized<StoppingClient>, public
EventSourceParser::Client { |
| 63 USING_GARBAGE_COLLECTED_MIXIN(StoppingClient); | 63 USING_GARBAGE_COLLECTED_MIXIN(StoppingClient); |
| 64 public: | 64 public: |
| 65 ~StoppingClient() override {} | 65 ~StoppingClient() override {} |
| 66 const Vector<EventOrReconnectionTimeSetting>& events() const { return m_even
ts; } | 66 const Vector<EventOrReconnectionTimeSetting>& events() const { return m_even
ts; } |
| 67 void setParser(EventSourceParser* parser) { m_parser = parser; } | 67 void setParser(EventSourceParser* parser) { m_parser = parser; } |
| 68 void onMessageEvent(const AtomicString& event, const String& data, const Ato
micString& id) override | 68 void onMessageEvent(const AtomicString& event, const String& data, const Ato
micString& id) override |
| 69 { | 69 { |
| 70 m_parser->stop(); | 70 m_parser->stop(); |
| 71 m_events.append(EventOrReconnectionTimeSetting(event, data, id)); | 71 m_events.append(EventOrReconnectionTimeSetting(event, data, id)); |
| 72 } | 72 } |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 ASSERT_EQ(1u, events.size()); | 398 ASSERT_EQ(1u, events.size()); |
| 399 ASSERT_EQ(EventOrReconnectionTimeSetting::Type::Event, events[0].type); | 399 ASSERT_EQ(EventOrReconnectionTimeSetting::Type::Event, events[0].type); |
| 400 EXPECT_EQ("message", events[0].event); | 400 EXPECT_EQ("message", events[0].event); |
| 401 EXPECT_EQ("hello", events[0].data); | 401 EXPECT_EQ("hello", events[0].data); |
| 402 EXPECT_EQ("99", parser->lastEventId()); | 402 EXPECT_EQ("99", parser->lastEventId()); |
| 403 } | 403 } |
| 404 | 404 |
| 405 } // namespace | 405 } // namespace |
| 406 | 406 |
| 407 } // namespace blink | 407 } // namespace blink |
| OLD | NEW |