privacy_container_view_unittest.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2020 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. #include "ash/app_list/views/privacy_container_view.h"
  5. #include <memory>
  6. #include "ash/app_list/app_list_test_view_delegate.h"
  7. #include "ash/app_list/views/suggested_content_info_view.h"
  8. #include "ash/public/cpp/test/test_app_list_color_provider.h"
  9. #include "ui/views/test/views_test_base.h"
  10. namespace ash {
  11. namespace test {
  12. class PrivacyContainerViewTest : public views::ViewsTestBase {
  13. public:
  14. PrivacyContainerViewTest() = default;
  15. ~PrivacyContainerViewTest() override = default;
  16. PrivacyContainerViewTest(const PrivacyContainerViewTest&) = delete;
  17. PrivacyContainerViewTest& operator=(const PrivacyContainerViewTest&) = delete;
  18. protected:
  19. AppListTestViewDelegate* view_delegate() { return &view_delegate_; }
  20. PrivacyContainerView* view() { return view_.get(); }
  21. SuggestedContentInfoView* suggested_content_view() {
  22. return view_->suggested_content_info_view_;
  23. }
  24. void CreateView() {
  25. view_ = std::make_unique<PrivacyContainerView>(&view_delegate_);
  26. view_->Update();
  27. }
  28. private:
  29. TestAppListColorProvider color_provider_; // Needed by AppListView.
  30. AppListTestViewDelegate view_delegate_;
  31. std::unique_ptr<PrivacyContainerView> view_;
  32. };
  33. TEST_F(PrivacyContainerViewTest, ShowSuggestedContentInfo) {
  34. view_delegate()->SetShouldShowSuggestedContentInfo(true);
  35. CreateView();
  36. // Only Suggested Content info should be visible.
  37. ASSERT_TRUE(suggested_content_view());
  38. EXPECT_TRUE(suggested_content_view()->GetVisible());
  39. EXPECT_EQ(view()->GetResultViewAt(0), suggested_content_view());
  40. // Disable Suggested Content info.
  41. view_delegate()->SetShouldShowSuggestedContentInfo(false);
  42. view()->Update();
  43. EXPECT_FALSE(suggested_content_view()->GetVisible());
  44. EXPECT_FALSE(view()->GetResultViewAt(0));
  45. }
  46. } // namespace test
  47. } // namespace ash