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 5 #ifndef CHROME_BROWSER_UI_ASH_HOLDING_SPACE_HOLDING_SPACE_BROWSERTEST_BASE_H_ 6 #define CHROME_BROWSER_UI_ASH_HOLDING_SPACE_HOLDING_SPACE_BROWSERTEST_BASE_H_ 7 8 #include <memory> 9 #include <vector> 10 11 #include "ash/public/cpp/holding_space/holding_space_item.h" 12 #include "base/test/scoped_feature_list.h" 13 #include "chrome/test/base/in_process_browser_test.h" 14 15 class Profile; 16 17 namespace aura { 18 class Window; 19 } // namespace aura 20 21 namespace views { 22 class View; 23 } // namespace views 24 25 namespace ash { 26 27 class HoldingSpaceItem; 28 class HoldingSpaceTestApi; 29 30 // Base class for holding space browser tests. 31 class HoldingSpaceBrowserTestBase : public InProcessBrowserTest { 32 public: 33 HoldingSpaceBrowserTestBase(); 34 ~HoldingSpaceBrowserTestBase() override; 35 36 // InProcessBrowserTest: 37 void SetUpInProcessBrowserTestFixture() override; 38 void SetUpOnMainThread() override; 39 40 // Returns the root window that newly created windows should be added to. 41 static aura::Window* GetRootWindowForNewWindows(); 42 43 // Returns the currently active profile. 44 Profile* GetProfile(); 45 46 // Shows holding space UI. This is a no-op if it's already showing. 47 void Show(); 48 49 // Closes holding space UI. This is a no-op if it's already closed. 50 void Close(); 51 52 // Returns true if holding space UI is showing, false otherwise. 53 bool IsShowing(); 54 55 // Returns true if the holding space tray is showing in the shelf, false 56 // otherwise. 57 bool IsShowingInShelf(); 58 59 // Adds and returns an arbitrary download file to the holding space. 60 HoldingSpaceItem* AddDownloadFile(); 61 62 // Adds and returns an arbitrary nearby share file to the holding space. 63 HoldingSpaceItem* AddNearbyShareFile(); 64 65 // Adds and returns an arbitrary pinned file to the holding space. 66 HoldingSpaceItem* AddPinnedFile(); 67 68 // Adds and returns an arbitrary screenshot file to the holding space. 69 HoldingSpaceItem* AddScreenshotFile(); 70 71 // Adds and returns an arbitrary screen recording file to the holding space. 72 HoldingSpaceItem* AddScreenRecordingFile(); 73 74 // Adds and returns a holding space item of the specified `type` backed by the 75 // file at the specified `file_path`. 76 HoldingSpaceItem* AddItem(Profile* profile, 77 HoldingSpaceItem::Type type, 78 const base::FilePath& file_path); 79 80 // Removes the specified holding space `item`. 81 void RemoveItem(const HoldingSpaceItem* item); 82 83 // Returns the collection of download chips in holding space UI. 84 // If holding space UI is not visible, an empty collection is returned. 85 std::vector<views::View*> GetDownloadChips(); 86 87 // Returns the collection of pinned file chips in holding space UI. 88 // If holding space UI is not visible, an empty collection is returned. 89 std::vector<views::View*> GetPinnedFileChips(); 90 91 // Returns the collection of screen capture views in holding space UI. 92 // If holding space UI is not visible, an empty collection is returned. 93 std::vector<views::View*> GetScreenCaptureViews(); 94 95 // Returns the holding space tray icon in the shelf. 96 views::View* GetTrayIcon(); 97 98 // Requests lock screen, waiting to return until session state is locked. 99 void RequestAndAwaitLockScreen(); 100 101 private: 102 base::test::ScopedFeatureList scoped_feature_list_; 103 std::unique_ptr<HoldingSpaceTestApi> test_api_; 104 }; 105 106 } // namespace ash 107 108 #endif // CHROME_BROWSER_UI_ASH_HOLDING_SPACE_HOLDING_SPACE_BROWSERTEST_BASE_H_ 109