| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 | 905 |
| 906 // We'll try to pass this dispatcher. | 906 // We'll try to pass this dispatcher. |
| 907 scoped_refptr<SharedBufferDispatcher> dispatcher; | 907 scoped_refptr<SharedBufferDispatcher> dispatcher; |
| 908 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( | 908 EXPECT_EQ(MOJO_RESULT_OK, SharedBufferDispatcher::Create( |
| 909 platform_support(), | 909 platform_support(), |
| 910 SharedBufferDispatcher::kDefaultCreateOptions, | 910 SharedBufferDispatcher::kDefaultCreateOptions, |
| 911 100, &dispatcher)); | 911 100, &dispatcher)); |
| 912 ASSERT_TRUE(dispatcher); | 912 ASSERT_TRUE(dispatcher); |
| 913 | 913 |
| 914 // Make a mapping. | 914 // Make a mapping. |
| 915 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping0; | 915 std::unique_ptr<embedder::PlatformSharedBufferMapping> mapping0; |
| 916 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->MapBuffer( | 916 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->MapBuffer( |
| 917 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping0)); | 917 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping0)); |
| 918 ASSERT_TRUE(mapping0); | 918 ASSERT_TRUE(mapping0); |
| 919 ASSERT_TRUE(mapping0->GetBase()); | 919 ASSERT_TRUE(mapping0->GetBase()); |
| 920 ASSERT_EQ(100u, mapping0->GetLength()); | 920 ASSERT_EQ(100u, mapping0->GetLength()); |
| 921 static_cast<char*>(mapping0->GetBase())[0] = 'A'; | 921 static_cast<char*>(mapping0->GetBase())[0] = 'A'; |
| 922 static_cast<char*>(mapping0->GetBase())[50] = 'B'; | 922 static_cast<char*>(mapping0->GetBase())[50] = 'B'; |
| 923 static_cast<char*>(mapping0->GetBase())[99] = 'C'; | 923 static_cast<char*>(mapping0->GetBase())[99] = 'C'; |
| 924 | 924 |
| 925 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do | 925 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 EXPECT_STREQ(kHello, read_buffer); | 972 EXPECT_STREQ(kHello, read_buffer); |
| 973 EXPECT_EQ(1u, read_dispatchers.size()); | 973 EXPECT_EQ(1u, read_dispatchers.size()); |
| 974 EXPECT_EQ(1u, read_num_dispatchers); | 974 EXPECT_EQ(1u, read_num_dispatchers); |
| 975 ASSERT_TRUE(read_dispatchers[0]); | 975 ASSERT_TRUE(read_dispatchers[0]); |
| 976 EXPECT_TRUE(read_dispatchers[0]->HasOneRef()); | 976 EXPECT_TRUE(read_dispatchers[0]->HasOneRef()); |
| 977 | 977 |
| 978 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, read_dispatchers[0]->GetType()); | 978 EXPECT_EQ(Dispatcher::Type::SHARED_BUFFER, read_dispatchers[0]->GetType()); |
| 979 dispatcher = static_cast<SharedBufferDispatcher*>(read_dispatchers[0].get()); | 979 dispatcher = static_cast<SharedBufferDispatcher*>(read_dispatchers[0].get()); |
| 980 | 980 |
| 981 // Make another mapping. | 981 // Make another mapping. |
| 982 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping1; | 982 std::unique_ptr<embedder::PlatformSharedBufferMapping> mapping1; |
| 983 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->MapBuffer( | 983 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->MapBuffer( |
| 984 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping1)); | 984 0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping1)); |
| 985 ASSERT_TRUE(mapping1); | 985 ASSERT_TRUE(mapping1); |
| 986 ASSERT_TRUE(mapping1->GetBase()); | 986 ASSERT_TRUE(mapping1->GetBase()); |
| 987 ASSERT_EQ(100u, mapping1->GetLength()); | 987 ASSERT_EQ(100u, mapping1->GetLength()); |
| 988 EXPECT_NE(mapping1->GetBase(), mapping0->GetBase()); | 988 EXPECT_NE(mapping1->GetBase(), mapping0->GetBase()); |
| 989 EXPECT_EQ('A', static_cast<char*>(mapping1->GetBase())[0]); | 989 EXPECT_EQ('A', static_cast<char*>(mapping1->GetBase())[0]); |
| 990 EXPECT_EQ('B', static_cast<char*>(mapping1->GetBase())[50]); | 990 EXPECT_EQ('B', static_cast<char*>(mapping1->GetBase())[50]); |
| 991 EXPECT_EQ('C', static_cast<char*>(mapping1->GetBase())[99]); | 991 EXPECT_EQ('C', static_cast<char*>(mapping1->GetBase())[99]); |
| 992 | 992 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 mp0->Close(0); | 1352 mp0->Close(0); |
| 1353 mp1->Close(1); | 1353 mp1->Close(1); |
| 1354 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 1354 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 1355 // Note that |local_mp|'s port 0 belong to |dispatcher|, which was closed. | 1355 // Note that |local_mp|'s port 0 belong to |dispatcher|, which was closed. |
| 1356 local_mp->Close(1); | 1356 local_mp->Close(1); |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 } // namespace | 1359 } // namespace |
| 1360 } // namespace system | 1360 } // namespace system |
| 1361 } // namespace mojo | 1361 } // namespace mojo |
| OLD | NEW |