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

Side by Side Diff: third_party/WebKit/Source/core/page/EventSourceTest.cpp

Issue 1264453002: Split the constructor of ThreadableLoader into two methods (ctor and start()) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed pipes around non-variables in a comment Created 4 years, 10 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
OLDNEW
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/EventSource.h" 5 #include "core/page/EventSource.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/ScriptValue.h" 9 #include "bindings/core/v8/ScriptValue.h"
10 #include "bindings/core/v8/SerializedScriptValue.h" 10 #include "bindings/core/v8/SerializedScriptValue.h"
11 #include "bindings/core/v8/V8Binding.h" 11 #include "bindings/core/v8/V8Binding.h"
12 #include "core/dom/ExecutionContext.h" 12 #include "core/dom/ExecutionContext.h"
13 #include "core/dom/MessagePort.h" 13 #include "core/dom/MessagePort.h"
14 #include "core/events/Event.h" 14 #include "core/events/Event.h"
15 #include "core/events/EventListener.h" 15 #include "core/events/EventListener.h"
16 #include "core/events/MessageEvent.h" 16 #include "core/events/MessageEvent.h"
17 #include "core/loader/MockThreadableLoader.h"
17 #include "core/page/EventSourceInit.h" 18 #include "core/page/EventSourceInit.h"
18 #include "core/testing/DummyPageHolder.h" 19 #include "core/testing/DummyPageHolder.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 #include <string.h> 22 #include <string.h>
22 #include <v8.h> 23 #include <v8.h>
23 24
24 namespace blink { 25 namespace blink {
25 26
26 namespace { 27 namespace {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 WillBeHeapVector<RefPtrWillBeMember<Event>> m_events; 61 WillBeHeapVector<RefPtrWillBeMember<Event>> m_events;
61 }; 62 };
62 63
63 class EventSourceTest : public ::testing::Test { 64 class EventSourceTest : public ::testing::Test {
64 protected: 65 protected:
65 EventSourceTest() 66 EventSourceTest()
66 : m_page(DummyPageHolder::create()) 67 : m_page(DummyPageHolder::create())
67 , m_source(EventSource::create(&document(), "https://localhost/", EventS ourceInit(), m_exceptionState)) 68 , m_source(EventSource::create(&document(), "https://localhost/", EventS ourceInit(), m_exceptionState))
68 { 69 {
69 source()->setStateForTest(EventSource::OPEN); 70 source()->setStateForTest(EventSource::OPEN);
70 source()->setRequestInFlightForTest(true); 71 source()->setThreadableLoaderForTest(MockThreadableLoader::create());
71 } 72 }
72 ~EventSourceTest() override 73 ~EventSourceTest() override
73 { 74 {
74 source()->setRequestInFlightForTest(false); 75 source()->setThreadableLoaderForTest(nullptr);
75 source()->close(); 76 source()->close();
76 77
77 // We need this because there is 78 // We need this because there is
78 // listener -> event -> source -> listener 79 // listener -> event -> source -> listener
79 // reference cycle on non-oilpan build. 80 // reference cycle on non-oilpan build.
80 m_source->removeAllEventListeners(); 81 m_source->removeAllEventListeners();
81 m_source = nullptr; 82 m_source = nullptr;
82 } 83 }
83 84
84 void enqueue(const char* data) { client()->didReceiveData(data, strlen(data) ); } 85 void enqueue(const char* data) { client()->didReceiveData(data, strlen(data) ); }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 ASSERT_EQ("message", messageListener->events()[0]->type()); 419 ASSERT_EQ("message", messageListener->events()[0]->type());
419 RefPtrWillBeRawPtr<MessageEvent> messageEvent = static_cast<MessageEvent*>(m essageListener->events()[0].get()); 420 RefPtrWillBeRawPtr<MessageEvent> messageEvent = static_cast<MessageEvent*>(m essageListener->events()[0].get());
420 ASSERT_EQ(MessageEvent::DataTypeSerializedScriptValue, messageEvent->dataTyp e()); 421 ASSERT_EQ(MessageEvent::DataTypeSerializedScriptValue, messageEvent->dataTyp e());
421 EXPECT_EQ("bye", dataAsString(scriptState(), messageEvent.get())); 422 EXPECT_EQ("bye", dataAsString(scriptState(), messageEvent.get()));
422 EXPECT_EQ("8", messageEvent->lastEventId()); 423 EXPECT_EQ("8", messageEvent->lastEventId());
423 } 424 }
424 425
425 } // namespace 426 } // namespace
426 427
427 } // namespace blink 428 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/EventSource.cpp ('k') | third_party/WebKit/Source/core/workers/WorkerScriptLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698