| Index: blimp/client/core/contents/blimp_contents_manager_unittest.cc
|
| diff --git a/blimp/client/core/contents/blimp_contents_manager_unittest.cc b/blimp/client/core/contents/blimp_contents_manager_unittest.cc
|
| index 422b77157ef9c49bbfd94dfc69fb02b1109ef2d3..f87040ee69d7bcd740cd3e9e5cca081e33527d44 100644
|
| --- a/blimp/client/core/contents/blimp_contents_manager_unittest.cc
|
| +++ b/blimp/client/core/contents/blimp_contents_manager_unittest.cc
|
| @@ -7,8 +7,12 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "blimp/client/core/contents/blimp_contents_impl.h"
|
| +#include "blimp/client/core/contents/tab_control_feature.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| +using testing::_;
|
| +
|
| namespace {
|
| const int kDummyTabId = 0;
|
| }
|
| @@ -17,10 +21,25 @@ namespace blimp {
|
| namespace client {
|
| namespace {
|
|
|
| +class MockTabControlFeature : public TabControlFeature {
|
| + public:
|
| + MockTabControlFeature() {}
|
| + ~MockTabControlFeature() override = default;
|
| +
|
| + MOCK_METHOD1(CreateTab, void(int));
|
| + MOCK_METHOD1(CloseTab, void(int));
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature);
|
| +};
|
| +
|
| TEST(BlimpContentsManagerUnittest, GetExistingBlimpContents) {
|
| base::MessageLoop loop;
|
| - BlimpContentsManager blimp_contents_manager;
|
| + MockTabControlFeature tab_control_feature;
|
|
|
| + BlimpContentsManager blimp_contents_manager(&tab_control_feature);
|
| +
|
| + EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1);
|
| std::unique_ptr<BlimpContentsImpl> blimp_contents =
|
| blimp_contents_manager.CreateBlimpContents();
|
| int id = blimp_contents->id();
|
| @@ -30,7 +49,9 @@ TEST(BlimpContentsManagerUnittest, GetExistingBlimpContents) {
|
| }
|
|
|
| TEST(BlimpContentsManagerUnittest, GetNonExistingBlimpContents) {
|
| - BlimpContentsManager blimp_contents_manager;
|
| + MockTabControlFeature tab_control_feature;
|
| +
|
| + BlimpContentsManager blimp_contents_manager(&tab_control_feature);
|
|
|
| BlimpContentsImpl* existing_contents =
|
| blimp_contents_manager.GetBlimpContents(kDummyTabId);
|
| @@ -39,15 +60,19 @@ TEST(BlimpContentsManagerUnittest, GetNonExistingBlimpContents) {
|
|
|
| TEST(BlimpContentsManagerUnittest, GetDestroyedBlimpContents) {
|
| base::MessageLoop loop;
|
| - BlimpContentsManager blimp_contents_manager;
|
| + MockTabControlFeature tab_control_feature;
|
| + BlimpContentsManager blimp_contents_manager(&tab_control_feature);
|
| int id;
|
|
|
| + EXPECT_CALL(tab_control_feature, CreateTab(_)).Times(1);
|
| std::unique_ptr<BlimpContentsImpl> blimp_contents =
|
| blimp_contents_manager.CreateBlimpContents();
|
| id = blimp_contents.get()->id();
|
| BlimpContentsImpl* existing_contents =
|
| blimp_contents_manager.GetBlimpContents(id);
|
| EXPECT_EQ(blimp_contents.get(), existing_contents);
|
| +
|
| + EXPECT_CALL(tab_control_feature, CloseTab(id)).Times(1);
|
| blimp_contents.reset();
|
|
|
| loop.RunUntilIdle();
|
|
|