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

Side by Side Diff: blimp/client/core/feedback/blimp_feedback_data_unittest.cc

Issue 2371503002: Add Blimp feedback data about visible BlimpContents. (Closed)
Patch Set: Rebased for good measure Created 4 years, 2 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
« no previous file with comments | « blimp/client/core/feedback/blimp_feedback_data.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/core/feedback/blimp_feedback_data.h" 5 #include "blimp/client/core/feedback/blimp_feedback_data.h"
6 6
7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h"
10 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h"
11 #include "blimp/client/core/contents/blimp_contents_impl.h"
12 #include "blimp/client/core/contents/blimp_contents_manager.h"
13 #include "blimp/client/core/contents/ime_feature.h"
14 #include "blimp/client/core/contents/tab_control_feature.h"
15 #include "blimp/client/core/render_widget/render_widget_feature.h"
16 #include "blimp/client/test/compositor/mock_compositor_dependencies.h"
17 #include "testing/gmock/include/gmock/gmock.h"
7 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/gfx/native_widget_types.h"
20
21 #if defined(OS_ANDROID)
22 #include "ui/android/window_android.h"
23 #endif // defined(OS_ANDROID)
8 24
9 namespace blimp { 25 namespace blimp {
10 namespace client { 26 namespace client {
11 namespace { 27 namespace {
12 28
13 TEST(BlimpFeedbackDataTest, IncludesBlimpIsSupported) { 29 class MockTabControlFeature : public TabControlFeature {
14 std::unordered_map<std::string, std::string> data = CreateBlimpFeedbackData(); 30 public:
31 MockTabControlFeature() {}
32 ~MockTabControlFeature() override = default;
33
34 MOCK_METHOD1(CreateTab, void(int));
35 MOCK_METHOD1(CloseTab, void(int));
36
37 private:
38 DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature);
39 };
40
41 class BlimpFeedbackDataTest : public testing::Test {
42 public:
43 BlimpFeedbackDataTest()
44 : compositor_deps_(base::MakeUnique<MockCompositorDependencies>()),
45 blimp_contents_manager_(&compositor_deps_,
46 &ime_feature_,
47 nullptr,
48 &render_widget_feature_,
49 &tab_control_feature_) {}
50
51 #if defined(OS_ANDROID)
52 void SetUp() override { window_ = ui::WindowAndroid::CreateForTesting(); }
53
54 void TearDown() override { window_->DestroyForTesting(); }
55 #endif // defined(OS_ANDROID)
56
57 protected:
58 gfx::NativeWindow window_ = nullptr;
59
60 base::MessageLoop loop_;
61 ImeFeature ime_feature_;
62 RenderWidgetFeature render_widget_feature_;
63 MockTabControlFeature tab_control_feature_;
64 BlimpCompositorDependencies compositor_deps_;
65 BlimpContentsManager blimp_contents_manager_;
66
67 private:
68 DISALLOW_COPY_AND_ASSIGN(BlimpFeedbackDataTest);
69 };
70
71 TEST_F(BlimpFeedbackDataTest, IncludesBlimpIsSupported) {
72 std::unordered_map<std::string, std::string> data =
73 CreateBlimpFeedbackData(&blimp_contents_manager_);
15 auto search = data.find(kFeedbackSupportedKey); 74 auto search = data.find(kFeedbackSupportedKey);
16 ASSERT_TRUE(search != data.end()); 75 ASSERT_TRUE(search != data.end());
17 EXPECT_EQ("true", search->second); 76 EXPECT_EQ("true", search->second);
18 } 77 }
19 78
79 TEST_F(BlimpFeedbackDataTest, CheckVisibilityCalculation) {
80 EXPECT_CALL(tab_control_feature_, CreateTab(testing::_)).Times(1);
81 std::unique_ptr<BlimpContentsImpl> blimp_contents =
82 blimp_contents_manager_.CreateBlimpContents(window_);
83
84 // Verify that visibility is false when there are no visible BlimpContents.
85 blimp_contents->Hide();
86 std::unordered_map<std::string, std::string> data =
87 CreateBlimpFeedbackData(&blimp_contents_manager_);
88 auto search = data.find(kFeedbackHasVisibleBlimpContents);
89 ASSERT_TRUE(search != data.end());
90 EXPECT_EQ("false", search->second);
91
92 // Verify that visibility is true when there are visible BlimpContents.
93 blimp_contents->Show();
94 data = CreateBlimpFeedbackData(&blimp_contents_manager_);
95 search = data.find(kFeedbackHasVisibleBlimpContents);
96 ASSERT_TRUE(search != data.end());
97 EXPECT_EQ("true", search->second);
98 }
99
20 } // namespace 100 } // namespace
21 } // namespace client 101 } // namespace client
22 } // namespace blimp 102 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/feedback/blimp_feedback_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698