| OLD | NEW |
| 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" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" | 10 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" |
| 11 #include "blimp/client/core/contents/blimp_contents_impl.h" | 11 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 12 #include "blimp/client/core/contents/blimp_contents_manager.h" | 12 #include "blimp/client/core/contents/blimp_contents_manager.h" |
| 13 #include "blimp/client/core/contents/ime_feature.h" | 13 #include "blimp/client/core/contents/ime_feature.h" |
| 14 #include "blimp/client/core/contents/tab_control_feature.h" | 14 #include "blimp/client/core/contents/tab_control_feature.h" |
| 15 #include "blimp/client/core/render_widget/render_widget_feature.h" | 15 #include "blimp/client/core/render_widget/render_widget_feature.h" |
| 16 #include "blimp/client/test/compositor/mock_compositor_dependencies.h" | 16 #include "blimp/client/test/compositor/mock_compositor_dependencies.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 20 | 20 |
| 21 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
| 22 #include "ui/android/window_android.h" | 22 #include "ui/android/window_android.h" |
| 23 #endif // defined(OS_ANDROID) | 23 #endif // defined(OS_ANDROID) |
| 24 | 24 |
| 25 const char kDefaultUserName[] = "mock_user"; |
| 26 |
| 25 namespace blimp { | 27 namespace blimp { |
| 26 namespace client { | 28 namespace client { |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 class MockTabControlFeature : public TabControlFeature { | 31 class MockTabControlFeature : public TabControlFeature { |
| 30 public: | 32 public: |
| 31 MockTabControlFeature() {} | 33 MockTabControlFeature() {} |
| 32 ~MockTabControlFeature() override = default; | 34 ~MockTabControlFeature() override = default; |
| 33 | 35 |
| 34 MOCK_METHOD1(CreateTab, void(int)); | 36 MOCK_METHOD1(CreateTab, void(int)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 63 MockTabControlFeature tab_control_feature_; | 65 MockTabControlFeature tab_control_feature_; |
| 64 BlimpCompositorDependencies compositor_deps_; | 66 BlimpCompositorDependencies compositor_deps_; |
| 65 BlimpContentsManager blimp_contents_manager_; | 67 BlimpContentsManager blimp_contents_manager_; |
| 66 | 68 |
| 67 private: | 69 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(BlimpFeedbackDataTest); | 70 DISALLOW_COPY_AND_ASSIGN(BlimpFeedbackDataTest); |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 TEST_F(BlimpFeedbackDataTest, IncludesBlimpIsSupported) { | 73 TEST_F(BlimpFeedbackDataTest, IncludesBlimpIsSupported) { |
| 72 std::unordered_map<std::string, std::string> data = | 74 std::unordered_map<std::string, std::string> data = |
| 73 CreateBlimpFeedbackData(&blimp_contents_manager_); | 75 CreateBlimpFeedbackData(&blimp_contents_manager_, kDefaultUserName); |
| 74 auto search = data.find(kFeedbackSupportedKey); | 76 auto search = data.find(kFeedbackSupportedKey); |
| 75 ASSERT_TRUE(search != data.end()); | 77 ASSERT_TRUE(search != data.end()); |
| 76 EXPECT_EQ("true", search->second); | 78 EXPECT_EQ("true", search->second); |
| 77 } | 79 } |
| 78 | 80 |
| 79 TEST_F(BlimpFeedbackDataTest, CheckVisibilityCalculation) { | 81 TEST_F(BlimpFeedbackDataTest, CheckVisibilityCalculation) { |
| 80 EXPECT_CALL(tab_control_feature_, CreateTab(testing::_)).Times(1); | 82 EXPECT_CALL(tab_control_feature_, CreateTab(testing::_)).Times(1); |
| 81 std::unique_ptr<BlimpContentsImpl> blimp_contents = | 83 std::unique_ptr<BlimpContentsImpl> blimp_contents = |
| 82 blimp_contents_manager_.CreateBlimpContents(window_); | 84 blimp_contents_manager_.CreateBlimpContents(window_); |
| 83 | 85 |
| 84 // Verify that visibility is false when there are no visible BlimpContents. | 86 // Verify that visibility is false when there are no visible BlimpContents. |
| 85 blimp_contents->Hide(); | 87 blimp_contents->Hide(); |
| 86 std::unordered_map<std::string, std::string> data = | 88 std::unordered_map<std::string, std::string> data = |
| 87 CreateBlimpFeedbackData(&blimp_contents_manager_); | 89 CreateBlimpFeedbackData(&blimp_contents_manager_, kDefaultUserName); |
| 88 auto search = data.find(kFeedbackHasVisibleBlimpContents); | 90 auto search = data.find(kFeedbackHasVisibleBlimpContents); |
| 89 ASSERT_TRUE(search != data.end()); | 91 ASSERT_TRUE(search != data.end()); |
| 90 EXPECT_EQ("false", search->second); | 92 EXPECT_EQ("false", search->second); |
| 91 | 93 |
| 92 // Verify that visibility is true when there are visible BlimpContents. | 94 // Verify that visibility is true when there are visible BlimpContents. |
| 93 blimp_contents->Show(); | 95 blimp_contents->Show(); |
| 94 data = CreateBlimpFeedbackData(&blimp_contents_manager_); | 96 data = CreateBlimpFeedbackData(&blimp_contents_manager_, kDefaultUserName); |
| 95 search = data.find(kFeedbackHasVisibleBlimpContents); | 97 search = data.find(kFeedbackHasVisibleBlimpContents); |
| 96 ASSERT_TRUE(search != data.end()); | 98 ASSERT_TRUE(search != data.end()); |
| 97 EXPECT_EQ("true", search->second); | 99 EXPECT_EQ("true", search->second); |
| 98 } | 100 } |
| 99 | 101 |
| 102 TEST_F(BlimpFeedbackDataTest, CheckUserName) { |
| 103 // Verify non-empty user name in the feedback data. |
| 104 std::unordered_map<std::string, std::string> data = |
| 105 CreateBlimpFeedbackData(&blimp_contents_manager_, kDefaultUserName); |
| 106 auto search = data.find(kFeedbackUserNameKey); |
| 107 ASSERT_TRUE(search != data.end()); |
| 108 EXPECT_EQ(kDefaultUserName, search->second); |
| 109 } |
| 110 |
| 111 TEST_F(BlimpFeedbackDataTest, CheckEmptyUserName) { |
| 112 // Verify empty user name in the feedback data. |
| 113 std::unordered_map<std::string, std::string> data = |
| 114 CreateBlimpFeedbackData(&blimp_contents_manager_, ""); |
| 115 auto search = data.find(kFeedbackUserNameKey); |
| 116 ASSERT_TRUE(search != data.end()); |
| 117 EXPECT_EQ("", search->second); |
| 118 } |
| 119 |
| 100 } // namespace | 120 } // namespace |
| 101 } // namespace client | 121 } // namespace client |
| 102 } // namespace blimp | 122 } // namespace blimp |
| OLD | NEW |