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

Side by Side Diff: content/browser/streams/stream_unittest.cc

Issue 637183002: Replace FINAL and OVERRIDE with their C++11 counterparts in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased the patch Created 6 years, 2 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/test/test_simple_task_runner.h" 6 #include "base/test/test_simple_task_runner.h"
7 #include "content/browser/streams/stream.h" 7 #include "content/browser/streams/stream.h"
8 #include "content/browser/streams/stream_read_observer.h" 8 #include "content/browser/streams/stream_read_observer.h"
9 #include "content/browser/streams/stream_registry.h" 9 #include "content/browser/streams/stream_registry.h"
10 #include "content/browser/streams/stream_write_observer.h" 10 #include "content/browser/streams/stream_write_observer.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class StreamTest : public testing::Test { 15 class StreamTest : public testing::Test {
16 public: 16 public:
17 StreamTest() : producing_seed_key_(0) {} 17 StreamTest() : producing_seed_key_(0) {}
18 18
19 virtual void SetUp() OVERRIDE { 19 virtual void SetUp() override {
20 registry_.reset(new StreamRegistry()); 20 registry_.reset(new StreamRegistry());
21 } 21 }
22 22
23 // Create a new IO buffer of the given |buffer_size| and fill it with random 23 // Create a new IO buffer of the given |buffer_size| and fill it with random
24 // data. 24 // data.
25 scoped_refptr<net::IOBuffer> NewIOBuffer(size_t buffer_size) { 25 scoped_refptr<net::IOBuffer> NewIOBuffer(size_t buffer_size) {
26 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(buffer_size)); 26 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(buffer_size));
27 char *bufferp = buffer->data(); 27 char *bufferp = buffer->data();
28 for (size_t i = 0; i < buffer_size; i++) 28 for (size_t i = 0; i < buffer_size; i++)
29 bufferp[i] = (i + producing_seed_key_) % (1 << sizeof(char)); 29 bufferp[i] = (i + producing_seed_key_) % (1 << sizeof(char));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 EXPECT_FALSE(completed_); 69 EXPECT_FALSE(completed_);
70 return; 70 return;
71 } 71 }
72 size_t old_capacity = buffer_->capacity(); 72 size_t old_capacity = buffer_->capacity();
73 buffer_->SetCapacity(old_capacity + bytes_read); 73 buffer_->SetCapacity(old_capacity + bytes_read);
74 memcpy(buffer_->StartOfBuffer() + old_capacity, 74 memcpy(buffer_->StartOfBuffer() + old_capacity,
75 buffer->data(), bytes_read); 75 buffer->data(), bytes_read);
76 } 76 }
77 } 77 }
78 78
79 virtual void OnDataAvailable(Stream* stream) OVERRIDE { 79 virtual void OnDataAvailable(Stream* stream) override {
80 Read(stream); 80 Read(stream);
81 } 81 }
82 82
83 scoped_refptr<net::GrowableIOBuffer> buffer() { return buffer_; } 83 scoped_refptr<net::GrowableIOBuffer> buffer() { return buffer_; }
84 84
85 bool completed() const { 85 bool completed() const {
86 return completed_; 86 return completed_;
87 } 87 }
88 88
89 private: 89 private:
90 scoped_refptr<net::GrowableIOBuffer> buffer_; 90 scoped_refptr<net::GrowableIOBuffer> buffer_;
91 bool completed_; 91 bool completed_;
92 }; 92 };
93 93
94 class TestStreamWriter : public StreamWriteObserver { 94 class TestStreamWriter : public StreamWriteObserver {
95 public: 95 public:
96 TestStreamWriter() {} 96 TestStreamWriter() {}
97 virtual ~TestStreamWriter() {} 97 virtual ~TestStreamWriter() {}
98 98
99 void Write(Stream* stream, 99 void Write(Stream* stream,
100 scoped_refptr<net::IOBuffer> buffer, 100 scoped_refptr<net::IOBuffer> buffer,
101 size_t buffer_size) { 101 size_t buffer_size) {
102 stream->AddData(buffer, buffer_size); 102 stream->AddData(buffer, buffer_size);
103 } 103 }
104 104
105 virtual void OnSpaceAvailable(Stream* stream) OVERRIDE { 105 virtual void OnSpaceAvailable(Stream* stream) override {
106 } 106 }
107 107
108 virtual void OnClose(Stream* stream) OVERRIDE { 108 virtual void OnClose(Stream* stream) override {
109 } 109 }
110 }; 110 };
111 111
112 TEST_F(StreamTest, SetReadObserver) { 112 TEST_F(StreamTest, SetReadObserver) {
113 TestStreamReader reader; 113 TestStreamReader reader;
114 TestStreamWriter writer; 114 TestStreamWriter writer;
115 115
116 GURL url("blob://stream"); 116 GURL url("blob://stream");
117 scoped_refptr<Stream> stream( 117 scoped_refptr<Stream> stream(
118 new Stream(registry_.get(), &writer, url)); 118 new Stream(registry_.get(), &writer, url));
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 302
303 // Run loop to make |reader| consume the data. 303 // Run loop to make |reader| consume the data.
304 base::MessageLoop::current()->RunUntilIdle(); 304 base::MessageLoop::current()->RunUntilIdle();
305 305
306 writer.Write(stream.get(), buffer, kBufferSize); 306 writer.Write(stream.get(), buffer, kBufferSize);
307 307
308 EXPECT_EQ(stream.get(), registry_->GetStream(url).get()); 308 EXPECT_EQ(stream.get(), registry_->GetStream(url).get());
309 } 309 }
310 310
311 } // namespace content 311 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/streams/stream_handle_impl.h ('k') | content/browser/streams/stream_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698