| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/edk/embedder/simple_platform_shared_buffer.h" | 5 #include "mojo/edk/embedder/simple_platform_shared_buffer.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 TEST(SimplePlatformSharedBufferTest, MappingsOutliveBuffer) { | 175 TEST(SimplePlatformSharedBufferTest, MappingsOutliveBuffer) { |
| 176 scoped_ptr<PlatformSharedBufferMapping> mapping1; | 176 scoped_ptr<PlatformSharedBufferMapping> mapping1; |
| 177 scoped_ptr<PlatformSharedBufferMapping> mapping2; | 177 scoped_ptr<PlatformSharedBufferMapping> mapping2; |
| 178 | 178 |
| 179 { | 179 { |
| 180 scoped_refptr<SimplePlatformSharedBuffer> buffer( | 180 scoped_refptr<SimplePlatformSharedBuffer> buffer( |
| 181 SimplePlatformSharedBuffer::Create(100)); | 181 SimplePlatformSharedBuffer::Create(100)); |
| 182 mapping1 = buffer->Map(0, 100).Pass(); | 182 mapping1 = buffer->Map(0, 100); |
| 183 mapping2 = buffer->Map(50, 50).Pass(); | 183 mapping2 = buffer->Map(50, 50); |
| 184 static_cast<char*>(mapping1->GetBase())[50] = 'x'; | 184 static_cast<char*>(mapping1->GetBase())[50] = 'x'; |
| 185 } | 185 } |
| 186 | 186 |
| 187 EXPECT_EQ('x', static_cast<char*>(mapping2->GetBase())[0]); | 187 EXPECT_EQ('x', static_cast<char*>(mapping2->GetBase())[0]); |
| 188 | 188 |
| 189 static_cast<char*>(mapping2->GetBase())[1] = 'y'; | 189 static_cast<char*>(mapping2->GetBase())[1] = 'y'; |
| 190 EXPECT_EQ('y', static_cast<char*>(mapping1->GetBase())[51]); | 190 EXPECT_EQ('y', static_cast<char*>(mapping1->GetBase())[51]); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace | 193 } // namespace |
| 194 } // namespace edk | 194 } // namespace edk |
| 195 } // namespace mojo | 195 } // namespace mojo |
| OLD | NEW |