| OLD | NEW | 
|---|
|  | (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/core/feedback/blimp_feedback_data.h" |  | 
| 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" |  | 
| 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) |  | 
| 24 |  | 
| 25 const char kDefaultUserName[] = "mock_user"; |  | 
| 26 |  | 
| 27 namespace blimp { |  | 
| 28 namespace client { |  | 
| 29 namespace { |  | 
| 30 |  | 
| 31 class MockTabControlFeature : public TabControlFeature { |  | 
| 32  public: |  | 
| 33   MockTabControlFeature() {} |  | 
| 34   ~MockTabControlFeature() override = default; |  | 
| 35 |  | 
| 36   MOCK_METHOD1(CreateTab, void(int)); |  | 
| 37   MOCK_METHOD1(CloseTab, void(int)); |  | 
| 38 |  | 
| 39  private: |  | 
| 40   DISALLOW_COPY_AND_ASSIGN(MockTabControlFeature); |  | 
| 41 }; |  | 
| 42 |  | 
| 43 class BlimpFeedbackDataTest : public testing::Test { |  | 
| 44  public: |  | 
| 45   BlimpFeedbackDataTest() |  | 
| 46       : compositor_deps_(base::MakeUnique<MockCompositorDependencies>()), |  | 
| 47         blimp_contents_manager_(&compositor_deps_, |  | 
| 48                                 &ime_feature_, |  | 
| 49                                 nullptr, |  | 
| 50                                 &render_widget_feature_, |  | 
| 51                                 &tab_control_feature_) {} |  | 
| 52 |  | 
| 53 #if defined(OS_ANDROID) |  | 
| 54   void SetUp() override { window_ = ui::WindowAndroid::CreateForTesting(); } |  | 
| 55 |  | 
| 56   void TearDown() override { window_->DestroyForTesting(); } |  | 
| 57 #endif  // defined(OS_ANDROID) |  | 
| 58 |  | 
| 59  protected: |  | 
| 60   gfx::NativeWindow window_ = nullptr; |  | 
| 61 |  | 
| 62   base::MessageLoop loop_; |  | 
| 63   ImeFeature ime_feature_; |  | 
| 64   RenderWidgetFeature render_widget_feature_; |  | 
| 65   MockTabControlFeature tab_control_feature_; |  | 
| 66   BlimpCompositorDependencies compositor_deps_; |  | 
| 67   BlimpContentsManager blimp_contents_manager_; |  | 
| 68 |  | 
| 69  private: |  | 
| 70   DISALLOW_COPY_AND_ASSIGN(BlimpFeedbackDataTest); |  | 
| 71 }; |  | 
| 72 |  | 
| 73 TEST_F(BlimpFeedbackDataTest, IncludesBlimpIsSupported) { |  | 
| 74   std::unordered_map<std::string, std::string> data = |  | 
| 75       CreateBlimpFeedbackData(&blimp_contents_manager_, kDefaultUserName); |  | 
| 76   auto search = data.find(kFeedbackSupportedKey); |  | 
| 77   ASSERT_TRUE(search != data.end()); |  | 
| 78   EXPECT_EQ("true", search->second); |  | 
| 79 } |  | 
| 80 |  | 
| 81 TEST_F(BlimpFeedbackDataTest, CheckVisibilityCalculation) { |  | 
| 82   EXPECT_CALL(tab_control_feature_, CreateTab(testing::_)).Times(1); |  | 
| 83   std::unique_ptr<BlimpContentsImpl> blimp_contents = |  | 
| 84       blimp_contents_manager_.CreateBlimpContents(window_); |  | 
| 85 |  | 
| 86   // Verify that visibility is false when there are no visible BlimpContents. |  | 
| 87   blimp_contents->Hide(); |  | 
| 88   std::unordered_map<std::string, std::string> data = |  | 
| 89       CreateBlimpFeedbackData(&blimp_contents_manager_, kDefaultUserName); |  | 
| 90   auto search = data.find(kFeedbackHasVisibleBlimpContents); |  | 
| 91   ASSERT_TRUE(search != data.end()); |  | 
| 92   EXPECT_EQ("false", search->second); |  | 
| 93 |  | 
| 94   // Verify that visibility is true when there are visible BlimpContents. |  | 
| 95   blimp_contents->Show(); |  | 
| 96   data = CreateBlimpFeedbackData(&blimp_contents_manager_, kDefaultUserName); |  | 
| 97   search = data.find(kFeedbackHasVisibleBlimpContents); |  | 
| 98   ASSERT_TRUE(search != data.end()); |  | 
| 99   EXPECT_EQ("true", search->second); |  | 
| 100 } |  | 
| 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 |  | 
| 120 }  // namespace |  | 
| 121 }  // namespace client |  | 
| 122 }  // namespace blimp |  | 
| OLD | NEW | 
|---|