예제 #1
0
TEST_F(ReadableStreamTest, Start)
{
    ScriptState::Scope scope(scriptState());
    ExceptionState exceptionState(ExceptionState::ConstructionContext, "property", "interface", scriptState()->context()->Global(), isolate());
    Checkpoint checkpoint;
    {
        InSequence s;
        EXPECT_CALL(checkpoint, Call(0));
        EXPECT_CALL(*m_underlyingSource, pullSource()).Times(1);
        EXPECT_CALL(checkpoint, Call(1));
    }

    StringStream* stream = new StringStream(m_underlyingSource);
    EXPECT_FALSE(exceptionState.hadException());
    EXPECT_FALSE(stream->isStarted());
    EXPECT_FALSE(stream->isDraining());
    EXPECT_FALSE(stream->isPulling());
    EXPECT_FALSE(stream->isDisturbed());
    EXPECT_EQ(stream->stateInternal(), ReadableStream::Readable);

    checkpoint.Call(0);
    stream->didSourceStart();
    checkpoint.Call(1);

    EXPECT_TRUE(stream->isStarted());
    EXPECT_FALSE(stream->isDraining());
    EXPECT_TRUE(stream->isPulling());
    EXPECT_EQ(stream->stateInternal(), ReadableStream::Readable);

    // We need to call |error| in order to make
    // ActiveDOMObject::hasPendingActivity return false.
    stream->error(DOMException::create(AbortError, "done"));
}
예제 #2
0
TEST_F(ReadableStreamTest, StrictStrategy)
{
    ScriptState::Scope scope(scriptState());
    ExceptionState exceptionState(ExceptionState::ConstructionContext, "property", "interface", scriptState()->context()->Global(), isolate());
    Checkpoint checkpoint;
    {
        InSequence s;
        EXPECT_CALL(checkpoint, Call(0));
        EXPECT_CALL(checkpoint, Call(1));
        EXPECT_CALL(*m_underlyingSource, pullSource());
        EXPECT_CALL(checkpoint, Call(2));
        EXPECT_CALL(checkpoint, Call(3));
        EXPECT_CALL(*m_underlyingSource, pullSource());
        EXPECT_CALL(checkpoint, Call(4));
        EXPECT_CALL(checkpoint, Call(5));
        EXPECT_CALL(checkpoint, Call(6));
        EXPECT_CALL(checkpoint, Call(7));
        EXPECT_CALL(checkpoint, Call(8));
        EXPECT_CALL(checkpoint, Call(9));
        EXPECT_CALL(*m_underlyingSource, pullSource());
    }
    StringStream* stream = new StringStream(m_underlyingSource, new StringStream::StrictStrategy);
    ReadableStreamReader* reader = stream->getReader(scriptState()->executionContext(), exceptionState);

    checkpoint.Call(0);
    stream->didSourceStart();

    checkpoint.Call(1);
    EXPECT_FALSE(stream->isPulling());
    reader->read(scriptState());
    EXPECT_TRUE(stream->isPulling());
    checkpoint.Call(2);
    stream->enqueue("hello");
    EXPECT_FALSE(stream->isPulling());
    checkpoint.Call(3);
    reader->read(scriptState());
    EXPECT_TRUE(stream->isPulling());
    checkpoint.Call(4);
    reader->read(scriptState());
    EXPECT_TRUE(stream->isPulling());
    checkpoint.Call(5);
    stream->enqueue("hello");
    EXPECT_FALSE(stream->isPulling());
    checkpoint.Call(6);
    stream->enqueue("hello");
    EXPECT_FALSE(stream->isPulling());
    checkpoint.Call(7);
    stream->enqueue("hello");
    EXPECT_FALSE(stream->isPulling());
    checkpoint.Call(8);
    reader->read(scriptState());
    EXPECT_FALSE(stream->isPulling());
    checkpoint.Call(9);
    reader->read(scriptState());
    EXPECT_TRUE(stream->isPulling());

    stream->error(DOMException::create(AbortError, "done"));
}
예제 #3
0
 StringStream* construct()
 {
     Checkpoint checkpoint;
     {
         InSequence s;
         EXPECT_CALL(checkpoint, Call(0));
         EXPECT_CALL(*m_underlyingSource, pullSource()).Times(1);
         EXPECT_CALL(checkpoint, Call(1));
     }
     StringStream* stream = new StringStream(m_underlyingSource, new PermissiveStrategy);
     checkpoint.Call(0);
     stream->didSourceStart();
     checkpoint.Call(1);
     return stream;
 }
예제 #4
0
 StringStream* construct(MockStrategy* strategy)
 {
     Checkpoint checkpoint;
     {
         InSequence s;
         EXPECT_CALL(checkpoint, Call(0));
         EXPECT_CALL(*strategy, shouldApplyBackpressure(0, _)).WillOnce(Return(true));
         EXPECT_CALL(checkpoint, Call(1));
     }
     StringStream* stream = new StringStream(m_underlyingSource, strategy);
     checkpoint.Call(0);
     stream->didSourceStart();
     checkpoint.Call(1);
     return stream;
 }