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

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

Issue 2292343002: Hooking up Blimp IME with BlimpContents (Closed)
Patch Set: Fixed linux client Created 4 years, 3 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
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/public/contents/blimp_contents_observer.h" 5 #include "blimp/client/public/contents/blimp_contents_observer.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" 8 #include "blimp/client/core/compositor/blimp_compositor_dependencies.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/ime_feature.h"
10 #include "blimp/client/core/render_widget/render_widget_feature.h" 11 #include "blimp/client/core/render_widget/render_widget_feature.h"
11 #include "blimp/client/support/compositor/mock_compositor_dependencies.h" 12 #include "blimp/client/support/compositor/mock_compositor_dependencies.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
15 16
16 #if defined(OS_ANDROID) 17 #if defined(OS_ANDROID)
17 #include "ui/android/window_android.h" 18 #include "ui/android/window_android.h"
18 #endif // defined(OS_ANDROID) 19 #endif // defined(OS_ANDROID)
19 20
(...skipping 28 matching lines...) Expand all
48 #endif // defined(OS_ANDROID) 49 #endif // defined(OS_ANDROID)
49 50
50 protected: 51 protected:
51 gfx::NativeWindow window_ = nullptr; 52 gfx::NativeWindow window_ = nullptr;
52 53
53 private: 54 private:
54 DISALLOW_COPY_AND_ASSIGN(BlimpContentsObserverTest); 55 DISALLOW_COPY_AND_ASSIGN(BlimpContentsObserverTest);
55 }; 56 };
56 57
57 TEST_F(BlimpContentsObserverTest, ObserverDies) { 58 TEST_F(BlimpContentsObserverTest, ObserverDies) {
59 ImeFeature ime_feature;
58 RenderWidgetFeature render_widget_feature; 60 RenderWidgetFeature render_widget_feature;
59 BlimpCompositorDependencies compositor_deps( 61 BlimpCompositorDependencies compositor_deps(
60 base::MakeUnique<MockCompositorDependencies>()); 62 base::MakeUnique<MockCompositorDependencies>());
61 BlimpContentsImpl contents(kDummyTabId, window_, &compositor_deps, nullptr, 63 BlimpContentsImpl contents(kDummyTabId, window_, &compositor_deps,
62 nullptr, &render_widget_feature, nullptr); 64 &ime_feature, nullptr, &render_widget_feature,
65 nullptr);
63 66
64 std::unique_ptr<BlimpContentsObserver> observer = 67 std::unique_ptr<BlimpContentsObserver> observer =
65 base::MakeUnique<TestBlimpContentsObserver>(&contents); 68 base::MakeUnique<TestBlimpContentsObserver>(&contents);
66 BlimpContentsObserver* observer_ptr = observer.get(); 69 BlimpContentsObserver* observer_ptr = observer.get();
67 EXPECT_TRUE(contents.HasObserver(observer_ptr)); 70 EXPECT_TRUE(contents.HasObserver(observer_ptr));
68 observer.reset(); 71 observer.reset();
69 72
70 EXPECT_FALSE(contents.HasObserver(observer_ptr)); 73 EXPECT_FALSE(contents.HasObserver(observer_ptr));
71 } 74 }
72 75
73 TEST_F(BlimpContentsObserverTest, ContentsDies) { 76 TEST_F(BlimpContentsObserverTest, ContentsDies) {
74 std::unique_ptr<TestBlimpContentsObserver> observer; 77 std::unique_ptr<TestBlimpContentsObserver> observer;
78 ImeFeature ime_feature;
75 RenderWidgetFeature render_widget_feature; 79 RenderWidgetFeature render_widget_feature;
76 BlimpCompositorDependencies compositor_deps( 80 BlimpCompositorDependencies compositor_deps(
77 base::MakeUnique<MockCompositorDependencies>()); 81 base::MakeUnique<MockCompositorDependencies>());
78 std::unique_ptr<BlimpContentsImpl> contents = 82 std::unique_ptr<BlimpContentsImpl> contents =
79 base::MakeUnique<BlimpContentsImpl>(kDummyTabId, window_, 83 base::MakeUnique<BlimpContentsImpl>(
80 &compositor_deps, nullptr, nullptr, 84 kDummyTabId, window_, &compositor_deps, &ime_feature, nullptr,
81 &render_widget_feature, nullptr); 85 &render_widget_feature, nullptr);
82 observer.reset(new TestBlimpContentsObserver(contents.get())); 86 observer.reset(new TestBlimpContentsObserver(contents.get()));
83 EXPECT_CALL(*observer, OnContentsDestroyed()).Times(1); 87 EXPECT_CALL(*observer, OnContentsDestroyed()).Times(1);
84 EXPECT_EQ(observer->blimp_contents(), contents.get()); 88 EXPECT_EQ(observer->blimp_contents(), contents.get());
85 contents.reset(); 89 contents.reset();
86 90
87 EXPECT_EQ(observer->blimp_contents(), nullptr); 91 EXPECT_EQ(observer->blimp_contents(), nullptr);
88 } 92 }
89 93
90 } // namespace 94 } // namespace
91 95
92 } // namespace client 96 } // namespace client
93 } // namespace blimp 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.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698