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.
5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_
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"
14 namespace extensions
{
16 class TestGuestViewManager
: public GuestViewManager
{
18 explicit TestGuestViewManager(content::BrowserContext
* context
);
19 ~TestGuestViewManager() override
;
21 void WaitForAllGuestsDeleted();
22 content::WebContents
* WaitForSingleGuestCreated();
24 content::WebContents
* GetLastGuestCreated();
27 // GuestViewManager override:
28 void AddGuest(int guest_instance_id
,
29 content::WebContents
* guest_web_contents
) override
;
30 void RemoveGuest(int guest_instance_id
) override
;
32 int GetNumGuests() const;
33 void WaitForGuestCreated();
35 std::vector
<linked_ptr
<content::WebContentsDestroyedWatcher
>>
36 guest_web_contents_watchers_
;
37 scoped_refptr
<content::MessageLoopRunner
> created_message_loop_runner_
;
39 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManager
);
42 // Test factory for creating test instances of GuestViewManager.
43 class TestGuestViewManagerFactory
: public GuestViewManagerFactory
{
45 TestGuestViewManagerFactory();
46 ~TestGuestViewManagerFactory() override
;
48 GuestViewManager
* CreateGuestViewManager(
49 content::BrowserContext
* context
) override
;
51 TestGuestViewManager
* GetManager(content::BrowserContext
* context
);
54 TestGuestViewManager
* test_guest_view_manager_
;
56 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManagerFactory
);
59 } // namespace extensions
61 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_TEST_GUEST_VIEW_MANAGER_H_