| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ | |
| 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ | |
| 7 | |
| 8 #include "base/memory/linked_ptr.h" | |
| 9 #include "content/public/test/browser_test_utils.h" | |
| 10 #include "content/public/test/test_utils.h" | |
| 11 #include "extensions/browser/guest_view/guest_view_manager.h" | |
| 12 #include "extensions/browser/guest_view/guest_view_manager_factory.h" | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 class TestGuestViewManager : public GuestViewManager { | |
| 17 public: | |
| 18 TestGuestViewManager( | |
| 19 content::BrowserContext* context, | |
| 20 scoped_ptr<guestview::GuestViewManagerDelegate> delegate); | |
| 21 ~TestGuestViewManager() override; | |
| 22 | |
| 23 void WaitForAllGuestsDeleted(); | |
| 24 content::WebContents* WaitForSingleGuestCreated(); | |
| 25 | |
| 26 content::WebContents* GetLastGuestCreated(); | |
| 27 | |
| 28 // Returns the number of guests currently still alive at the time of calling | |
| 29 // this method. | |
| 30 int GetNumGuestsActive() const; | |
| 31 | |
| 32 // Returns the size of the set of removed instance IDs. | |
| 33 int GetNumRemovedInstanceIDs() const; | |
| 34 | |
| 35 // Returns the number of guests that have been created since the creation of | |
| 36 // this GuestViewManager. | |
| 37 int num_guests_created() const { return num_guests_created_; } | |
| 38 | |
| 39 // Returns the last guest instance ID removed from the manager. | |
| 40 int last_instance_id_removed() const { return last_instance_id_removed_; } | |
| 41 | |
| 42 private: | |
| 43 FRIEND_TEST_ALL_PREFIXES(GuestViewManagerTest, AddRemove); | |
| 44 | |
| 45 // GuestViewManager override: | |
| 46 void AddGuest(int guest_instance_id, | |
| 47 content::WebContents* guest_web_contents) override; | |
| 48 void RemoveGuest(int guest_instance_id) override; | |
| 49 | |
| 50 void WaitForGuestCreated(); | |
| 51 | |
| 52 using GuestViewManager::last_instance_id_removed_; | |
| 53 using GuestViewManager::removed_instance_ids_; | |
| 54 | |
| 55 int num_guests_created_; | |
| 56 | |
| 57 std::vector<linked_ptr<content::WebContentsDestroyedWatcher>> | |
| 58 guest_web_contents_watchers_; | |
| 59 scoped_refptr<content::MessageLoopRunner> created_message_loop_runner_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManager); | |
| 62 }; | |
| 63 | |
| 64 // Test factory for creating test instances of GuestViewManager. | |
| 65 class TestGuestViewManagerFactory : public GuestViewManagerFactory { | |
| 66 public: | |
| 67 TestGuestViewManagerFactory(); | |
| 68 ~TestGuestViewManagerFactory() override; | |
| 69 | |
| 70 GuestViewManager* CreateGuestViewManager( | |
| 71 content::BrowserContext* context, | |
| 72 scoped_ptr<guestview::GuestViewManagerDelegate> delegate) override; | |
| 73 | |
| 74 private: | |
| 75 TestGuestViewManager* test_guest_view_manager_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManagerFactory); | |
| 78 }; | |
| 79 | |
| 80 } // namespace extensions | |
| 81 | |
| 82 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_ | |
| OLD | NEW |