| Index: trunk/src/net/spdy/spdy_write_queue_unittest.cc
|
| ===================================================================
|
| --- trunk/src/net/spdy/spdy_write_queue_unittest.cc (revision 194561)
|
| +++ trunk/src/net/spdy/spdy_write_queue_unittest.cc (working copy)
|
| @@ -14,7 +14,7 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "net/base/net_log.h"
|
| #include "net/base/request_priority.h"
|
| -#include "net/spdy/spdy_buffer_producer.h"
|
| +#include "net/spdy/spdy_frame_producer.h"
|
| #include "net/spdy/spdy_stream.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -26,33 +26,31 @@
|
|
|
| // Makes a SpdyFrameProducer producing a frame with the data in the
|
| // given string.
|
| -scoped_ptr<SpdyBufferProducer> StringToProducer(const std::string& s) {
|
| +scoped_ptr<SpdyFrameProducer> StringToProducer(const std::string& s) {
|
| scoped_ptr<char[]> data(new char[s.size()]);
|
| std::memcpy(data.get(), s.data(), s.size());
|
| - return scoped_ptr<SpdyBufferProducer>(
|
| - new SimpleBufferProducer(
|
| - scoped_ptr<SpdyBuffer>(
|
| - new SpdyBuffer(
|
| - scoped_ptr<SpdyFrame>(
|
| - new SpdyFrame(data.release(), s.size(), true))))));
|
| + return scoped_ptr<SpdyFrameProducer>(
|
| + new SimpleFrameProducer(
|
| + scoped_ptr<SpdyFrame>(
|
| + new SpdyFrame(data.release(), s.size(), true))));
|
| }
|
|
|
| -// Makes a SpdyBufferProducer producing a frame with the data in the
|
| +// Makes a SpdyFrameProducer producing a frame with the data in the
|
| // given int (converted to a string).
|
| -scoped_ptr<SpdyBufferProducer> IntToProducer(int i) {
|
| +scoped_ptr<SpdyFrameProducer> IntToProducer(int i) {
|
| return StringToProducer(base::IntToString(i));
|
| }
|
|
|
| // Produces a frame with the given producer and returns a copy of its
|
| // data as a string.
|
| -std::string ProducerToString(scoped_ptr<SpdyBufferProducer> producer) {
|
| - scoped_ptr<SpdyBuffer> buffer = producer->ProduceBuffer();
|
| - return std::string(buffer->GetRemainingData(), buffer->GetRemainingSize());
|
| +std::string ProducerToString(scoped_ptr<SpdyFrameProducer> producer) {
|
| + scoped_ptr<SpdyFrame> frame = producer->ProduceFrame();
|
| + return std::string(frame->data(), frame->size());
|
| }
|
|
|
| // Produces a frame with the given producer and returns a copy of its
|
| // data as an int (converted from a string).
|
| -int ProducerToInt(scoped_ptr<SpdyBufferProducer> producer) {
|
| +int ProducerToInt(scoped_ptr<SpdyFrameProducer> producer) {
|
| int i = 0;
|
| EXPECT_TRUE(base::StringToInt(ProducerToString(producer.Pass()), &i));
|
| return i;
|
| @@ -71,9 +69,9 @@
|
| TEST_F(SpdyWriteQueueTest, DequeuesByPriority) {
|
| SpdyWriteQueue write_queue;
|
|
|
| - scoped_ptr<SpdyBufferProducer> producer_low = StringToProducer("LOW");
|
| - scoped_ptr<SpdyBufferProducer> producer_medium = StringToProducer("MEDIUM");
|
| - scoped_ptr<SpdyBufferProducer> producer_highest = StringToProducer("HIGHEST");
|
| + scoped_ptr<SpdyFrameProducer> producer_low = StringToProducer("LOW");
|
| + scoped_ptr<SpdyFrameProducer> producer_medium = StringToProducer("MEDIUM");
|
| + scoped_ptr<SpdyFrameProducer> producer_highest = StringToProducer("HIGHEST");
|
|
|
| // A NULL stream should still work.
|
| scoped_refptr<SpdyStream> stream_low(NULL);
|
| @@ -88,7 +86,7 @@
|
| HIGHEST, RST_STREAM, producer_highest.Pass(), stream_highest);
|
|
|
| SpdyFrameType frame_type = DATA;
|
| - scoped_ptr<SpdyBufferProducer> frame_producer;
|
| + scoped_ptr<SpdyFrameProducer> frame_producer;
|
| scoped_refptr<SpdyStream> stream;
|
| ASSERT_TRUE(write_queue.Dequeue(&frame_type, &frame_producer, &stream));
|
| EXPECT_EQ(RST_STREAM, frame_type);
|
| @@ -113,9 +111,9 @@
|
| TEST_F(SpdyWriteQueueTest, DequeuesFIFO) {
|
| SpdyWriteQueue write_queue;
|
|
|
| - scoped_ptr<SpdyBufferProducer> producer1 = IntToProducer(1);
|
| - scoped_ptr<SpdyBufferProducer> producer2 = IntToProducer(2);
|
| - scoped_ptr<SpdyBufferProducer> producer3 = IntToProducer(3);
|
| + scoped_ptr<SpdyFrameProducer> producer1 = IntToProducer(1);
|
| + scoped_ptr<SpdyFrameProducer> producer2 = IntToProducer(2);
|
| + scoped_ptr<SpdyFrameProducer> producer3 = IntToProducer(3);
|
|
|
| scoped_refptr<SpdyStream> stream1(MakeTestStream(DEFAULT_PRIORITY));
|
| scoped_refptr<SpdyStream> stream2(MakeTestStream(DEFAULT_PRIORITY));
|
| @@ -126,7 +124,7 @@
|
| write_queue.Enqueue(DEFAULT_PRIORITY, RST_STREAM, producer3.Pass(), stream3);
|
|
|
| SpdyFrameType frame_type = DATA;
|
| - scoped_ptr<SpdyBufferProducer> frame_producer;
|
| + scoped_ptr<SpdyFrameProducer> frame_producer;
|
| scoped_refptr<SpdyStream> stream;
|
| ASSERT_TRUE(write_queue.Dequeue(&frame_type, &frame_producer, &stream));
|
| EXPECT_EQ(SYN_STREAM, frame_type);
|
| @@ -164,7 +162,7 @@
|
|
|
| for (int i = 0; i < 100; i += 3) {
|
| SpdyFrameType frame_type = DATA;
|
| - scoped_ptr<SpdyBufferProducer> frame_producer;
|
| + scoped_ptr<SpdyFrameProducer> frame_producer;
|
| scoped_refptr<SpdyStream> stream;
|
| ASSERT_TRUE(write_queue.Dequeue(&frame_type, &frame_producer, &stream));
|
| EXPECT_EQ(SYN_STREAM, frame_type);
|
| @@ -173,7 +171,7 @@
|
| }
|
|
|
| SpdyFrameType frame_type = DATA;
|
| - scoped_ptr<SpdyBufferProducer> frame_producer;
|
| + scoped_ptr<SpdyFrameProducer> frame_producer;
|
| scoped_refptr<SpdyStream> stream;
|
| EXPECT_FALSE(write_queue.Dequeue(&frame_type, &frame_producer, &stream));
|
| }
|
| @@ -191,11 +189,11 @@
|
| write_queue.Clear();
|
|
|
| SpdyFrameType frame_type = DATA;
|
| - scoped_ptr<SpdyBufferProducer> frame_producer;
|
| + scoped_ptr<SpdyFrameProducer> frame_producer;
|
| scoped_refptr<SpdyStream> stream;
|
| EXPECT_FALSE(write_queue.Dequeue(&frame_type, &frame_producer, &stream));
|
| }
|
|
|
| -} // namespace
|
| +}
|
|
|
| } // namespace net
|
|
|