| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/contents/blimp_contents_manager.h" | 5 #include "blimp/client/core/contents/blimp_contents_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "blimp/client/core/contents/blimp_contents_impl.h" | 9 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 const int kDummyTabId = 0; | 13 const int kDummyTabId = 0; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace blimp { | 16 namespace blimp { |
| 17 namespace client { | 17 namespace client { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 TEST(BlimpContentsManagerUnittest, GetExistingBlimpContents) { | 20 TEST(BlimpContentsManagerUnittest, GetExistingBlimpContents) { |
| 21 base::MessageLoop loop; | 21 base::MessageLoop loop; |
| 22 BlimpContentsManager blimp_contents_manager; | 22 BlimpContentsManager blimp_contents_manager; |
| 23 | 23 |
| 24 std::unique_ptr<BlimpContentsImpl> blimp_contents = | 24 std::unique_ptr<BlimpContentsImpl> blimp_contents = |
| 25 blimp_contents_manager.CreateBlimpContents(); | 25 blimp_contents_manager.CreateBlimpContents(nullptr, nullptr); |
| 26 int id = blimp_contents->id(); | 26 int id = blimp_contents->id(); |
| 27 BlimpContentsImpl* existing_contents = | 27 BlimpContentsImpl* existing_contents = |
| 28 blimp_contents_manager.GetBlimpContents(id); | 28 blimp_contents_manager.GetBlimpContents(id); |
| 29 EXPECT_EQ(blimp_contents.get(), existing_contents); | 29 EXPECT_EQ(blimp_contents.get(), existing_contents); |
| 30 } | 30 } |
| 31 | 31 |
| 32 TEST(BlimpContentsManagerUnittest, GetNonExistingBlimpContents) { | 32 TEST(BlimpContentsManagerUnittest, GetNonExistingBlimpContents) { |
| 33 BlimpContentsManager blimp_contents_manager; | 33 BlimpContentsManager blimp_contents_manager; |
| 34 | 34 |
| 35 BlimpContentsImpl* existing_contents = | 35 BlimpContentsImpl* existing_contents = |
| 36 blimp_contents_manager.GetBlimpContents(kDummyTabId); | 36 blimp_contents_manager.GetBlimpContents(kDummyTabId); |
| 37 EXPECT_EQ(nullptr, existing_contents); | 37 EXPECT_EQ(nullptr, existing_contents); |
| 38 } | 38 } |
| 39 | 39 |
| 40 TEST(BlimpContentsManagerUnittest, GetDestroyedBlimpContents) { | 40 TEST(BlimpContentsManagerUnittest, GetDestroyedBlimpContents) { |
| 41 base::MessageLoop loop; | 41 base::MessageLoop loop; |
| 42 BlimpContentsManager blimp_contents_manager; | 42 BlimpContentsManager blimp_contents_manager; |
| 43 int id; | 43 int id; |
| 44 | 44 |
| 45 std::unique_ptr<BlimpContentsImpl> blimp_contents = | 45 std::unique_ptr<BlimpContentsImpl> blimp_contents = |
| 46 blimp_contents_manager.CreateBlimpContents(); | 46 blimp_contents_manager.CreateBlimpContents(nullptr, nullptr); |
| 47 id = blimp_contents.get()->id(); | 47 id = blimp_contents.get()->id(); |
| 48 BlimpContentsImpl* existing_contents = | 48 BlimpContentsImpl* existing_contents = |
| 49 blimp_contents_manager.GetBlimpContents(id); | 49 blimp_contents_manager.GetBlimpContents(id); |
| 50 EXPECT_EQ(blimp_contents.get(), existing_contents); | 50 EXPECT_EQ(blimp_contents.get(), existing_contents); |
| 51 blimp_contents.reset(); | 51 blimp_contents.reset(); |
| 52 | 52 |
| 53 loop.RunUntilIdle(); | 53 loop.RunUntilIdle(); |
| 54 EXPECT_EQ(nullptr, blimp_contents_manager.GetBlimpContents(id)); | 54 EXPECT_EQ(nullptr, blimp_contents_manager.GetBlimpContents(id)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 } // namespace client | 58 } // namespace client |
| 59 } // namespace blimp | 59 } // namespace blimp |
| OLD | NEW |