Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: blimp/client/core/contents/blimp_contents_observer_unittest.cc

Issue 2624903006: Remove all blimp client code. (Closed)
Patch Set: Update buildbot configuration Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/public/contents/blimp_contents_observer.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h"
9 #include "blimp/client/core/contents/blimp_contents_impl.h"
10 #include "blimp/client/core/contents/ime_feature.h"
11 #include "blimp/client/core/render_widget/render_widget_feature.h"
12 #include "blimp/client/test/compositor/mock_compositor_dependencies.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gfx/native_widget_types.h"
16
17 #if defined(OS_ANDROID)
18 #include "ui/android/window_android.h"
19 #endif // defined(OS_ANDROID)
20
21 namespace {
22 const int kDummyBlimpContentsId = 0;
23 }
24
25 namespace blimp {
26 namespace client {
27
28 namespace {
29
30 class TestBlimpContentsObserver : public BlimpContentsObserver {
31 public:
32 explicit TestBlimpContentsObserver(BlimpContents* blimp_contents)
33 : BlimpContentsObserver(blimp_contents) {}
34
35 MOCK_METHOD0(OnContentsDestroyed, void());
36
37 private:
38 DISALLOW_COPY_AND_ASSIGN(TestBlimpContentsObserver);
39 };
40
41 class BlimpContentsObserverTest : public testing::Test {
42 public:
43 BlimpContentsObserverTest() = default;
44
45 #if defined(OS_ANDROID)
46 void SetUp() override { window_ = ui::WindowAndroid::CreateForTesting(); }
47
48 void TearDown() override { window_->DestroyForTesting(); }
49 #endif // defined(OS_ANDROID)
50
51 protected:
52 gfx::NativeWindow window_ = nullptr;
53
54 private:
55 DISALLOW_COPY_AND_ASSIGN(BlimpContentsObserverTest);
56 };
57
58 TEST_F(BlimpContentsObserverTest, ObserverDies) {
59 ImeFeature ime_feature;
60 RenderWidgetFeature render_widget_feature;
61 BlimpCompositorDependencies compositor_deps(
62 base::MakeUnique<MockCompositorDependencies>());
63 BlimpContentsImpl contents(kDummyBlimpContentsId, window_, &compositor_deps,
64 &ime_feature, nullptr, &render_widget_feature,
65 nullptr);
66
67 std::unique_ptr<BlimpContentsObserver> observer =
68 base::MakeUnique<TestBlimpContentsObserver>(&contents);
69 BlimpContentsObserver* observer_ptr = observer.get();
70 EXPECT_TRUE(contents.HasObserver(observer_ptr));
71 observer.reset();
72
73 EXPECT_FALSE(contents.HasObserver(observer_ptr));
74 }
75
76 TEST_F(BlimpContentsObserverTest, ContentsDies) {
77 std::unique_ptr<TestBlimpContentsObserver> observer;
78 ImeFeature ime_feature;
79 RenderWidgetFeature render_widget_feature;
80 BlimpCompositorDependencies compositor_deps(
81 base::MakeUnique<MockCompositorDependencies>());
82 std::unique_ptr<BlimpContentsImpl> contents =
83 base::MakeUnique<BlimpContentsImpl>(
84 kDummyBlimpContentsId, window_, &compositor_deps, &ime_feature,
85 nullptr, &render_widget_feature, nullptr);
86 observer.reset(new TestBlimpContentsObserver(contents.get()));
87 EXPECT_CALL(*observer, OnContentsDestroyed()).Times(1);
88 EXPECT_EQ(observer->blimp_contents(), contents.get());
89 contents.reset();
90
91 EXPECT_EQ(observer->blimp_contents(), nullptr);
92 }
93
94 } // namespace
95
96 } // namespace client
97 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/contents/blimp_contents_manager_unittest.cc ('k') | blimp/client/core/contents/blimp_contents_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698