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