| 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 "blimp/client/core/contents/tab_control_feature.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 TEST(BlimpContentsManagerUnittest, GetExistingBlimpContents) { | 36 TEST(BlimpContentsManagerUnittest, GetExistingBlimpContents) { |
| 37 base::MessageLoop loop; | 37 base::MessageLoop loop; |
| 38 MockTabControlFeature tab_control_feature; | 38 MockTabControlFeature tab_control_feature; |
| 39 | 39 |
| 40 BlimpContentsManager blimp_contents_manager(nullptr, nullptr, | 40 BlimpContentsManager blimp_contents_manager(nullptr, nullptr, |
| 41 &tab_control_feature); | 41 &tab_control_feature); |
| 42 | 42 |
| 43 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1); | 43 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1); |
| 44 std::unique_ptr<BlimpContentsImpl> blimp_contents = | 44 std::unique_ptr<BlimpContentsImpl> blimp_contents = |
| 45 blimp_contents_manager.CreateBlimpContents(); | 45 blimp_contents_manager.CreateBlimpContents(nullptr); |
| 46 int id = blimp_contents->id(); | 46 int id = blimp_contents->id(); |
| 47 BlimpContentsImpl* existing_contents = | 47 BlimpContentsImpl* existing_contents = |
| 48 blimp_contents_manager.GetBlimpContents(id); | 48 blimp_contents_manager.GetBlimpContents(id); |
| 49 EXPECT_EQ(blimp_contents.get(), existing_contents); | 49 EXPECT_EQ(blimp_contents.get(), existing_contents); |
| 50 } | 50 } |
| 51 | 51 |
| 52 TEST(BlimpContentsManagerUnittest, GetNonExistingBlimpContents) { | 52 TEST(BlimpContentsManagerUnittest, GetNonExistingBlimpContents) { |
| 53 MockTabControlFeature tab_control_feature; | 53 MockTabControlFeature tab_control_feature; |
| 54 | 54 |
| 55 BlimpContentsManager blimp_contents_manager(nullptr, nullptr, | 55 BlimpContentsManager blimp_contents_manager(nullptr, nullptr, |
| 56 &tab_control_feature); | 56 &tab_control_feature); |
| 57 | 57 |
| 58 BlimpContentsImpl* existing_contents = | 58 BlimpContentsImpl* existing_contents = |
| 59 blimp_contents_manager.GetBlimpContents(kDummyTabId); | 59 blimp_contents_manager.GetBlimpContents(kDummyTabId); |
| 60 EXPECT_EQ(nullptr, existing_contents); | 60 EXPECT_EQ(nullptr, existing_contents); |
| 61 } | 61 } |
| 62 | 62 |
| 63 TEST(BlimpContentsManagerUnittest, GetDestroyedBlimpContents) { | 63 TEST(BlimpContentsManagerUnittest, GetDestroyedBlimpContents) { |
| 64 base::MessageLoop loop; | 64 base::MessageLoop loop; |
| 65 MockTabControlFeature tab_control_feature; | 65 MockTabControlFeature tab_control_feature; |
| 66 BlimpContentsManager blimp_contents_manager(nullptr, nullptr, | 66 BlimpContentsManager blimp_contents_manager(nullptr, nullptr, |
| 67 &tab_control_feature); | 67 &tab_control_feature); |
| 68 int id; | 68 int id; |
| 69 | 69 |
| 70 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1); | 70 EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1); |
| 71 std::unique_ptr<BlimpContentsImpl> blimp_contents = | 71 std::unique_ptr<BlimpContentsImpl> blimp_contents = |
| 72 blimp_contents_manager.CreateBlimpContents(); | 72 blimp_contents_manager.CreateBlimpContents(nullptr); |
| 73 id = blimp_contents.get()->id(); | 73 id = blimp_contents.get()->id(); |
| 74 BlimpContentsImpl* existing_contents = | 74 BlimpContentsImpl* existing_contents = |
| 75 blimp_contents_manager.GetBlimpContents(id); | 75 blimp_contents_manager.GetBlimpContents(id); |
| 76 EXPECT_EQ(blimp_contents.get(), existing_contents); | 76 EXPECT_EQ(blimp_contents.get(), existing_contents); |
| 77 | 77 |
| 78 EXPECT_CALL(tab_control_feature, CloseTab(id)).Times(1); | 78 EXPECT_CALL(tab_control_feature, CloseTab(id)).Times(1); |
| 79 blimp_contents.reset(); | 79 blimp_contents.reset(); |
| 80 | 80 |
| 81 loop.RunUntilIdle(); | 81 loop.RunUntilIdle(); |
| 82 EXPECT_EQ(nullptr, blimp_contents_manager.GetBlimpContents(id)); | 82 EXPECT_EQ(nullptr, blimp_contents_manager.GetBlimpContents(id)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 } // namespace client | 86 } // namespace client |
| 87 } // namespace blimp | 87 } // namespace blimp |
| OLD | NEW |