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