OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/guest_view/guest_view_manager.h" | 5 #include "extensions/browser/guest_view/guest_view_manager.h" |
6 | 6 |
7 #include "content/public/browser/notification_service.h" | 7 #include "content/public/browser/notification_service.h" |
8 #include "content/public/test/test_browser_context.h" | 8 #include "content/public/test/test_browser_context.h" |
9 #include "content/public/test/test_browser_thread_bundle.h" | 9 #include "content/public/test/test_browser_thread_bundle.h" |
10 #include "content/public/test/web_contents_tester.h" | 10 #include "content/public/test/web_contents_tester.h" |
11 #include "extensions/browser/extensions_test.h" | 11 #include "extensions/browser/extensions_test.h" |
| 12 #include "extensions/browser/guest_view/extensions_guest_view_manager_delegate.h
" |
| 13 #include "extensions/browser/guest_view/guest_view_manager.h" |
| 14 #include "extensions/browser/guest_view/guest_view_manager_delegate.h" |
12 | 15 |
13 using content::WebContents; | 16 using content::WebContents; |
14 using content::WebContentsTester; | 17 using content::WebContentsTester; |
| 18 using guestview::GuestViewManagerDelegate; |
15 | 19 |
16 namespace extensions { | 20 namespace extensions { |
17 | 21 |
18 namespace guestview { | 22 namespace guestview { |
19 | 23 |
20 // This class allows us to access some private variables in | 24 // This class allows us to access some private variables in |
21 // GuestViewManager. | 25 // GuestViewManager. |
22 class TestGuestViewManager : public GuestViewManager { | 26 class TestGuestViewManager : public GuestViewManager { |
23 public: | 27 public: |
24 explicit TestGuestViewManager(content::BrowserContext* context) | 28 TestGuestViewManager(content::BrowserContext* context, |
25 : GuestViewManager(context) {} | 29 scoped_ptr<GuestViewManagerDelegate> delegate) |
| 30 : GuestViewManager(context, delegate.Pass()) {} |
26 | 31 |
27 int last_instance_id_removed_for_testing() { | 32 int last_instance_id_removed_for_testing() { |
28 return last_instance_id_removed_; | 33 return last_instance_id_removed_; |
29 } | 34 } |
30 | 35 |
31 size_t GetRemovedInstanceIdSize() { return removed_instance_ids_.size(); } | 36 size_t GetRemovedInstanceIdSize() { return removed_instance_ids_.size(); } |
32 | 37 |
33 private: | 38 private: |
34 using GuestViewManager::last_instance_id_removed_; | 39 using GuestViewManager::last_instance_id_removed_; |
35 using GuestViewManager::removed_instance_ids_; | 40 using GuestViewManager::removed_instance_ids_; |
(...skipping 21 matching lines...) Expand all Loading... |
57 content::TestBrowserThreadBundle thread_bundle_; | 62 content::TestBrowserThreadBundle thread_bundle_; |
58 content::TestBrowserContext browser_context_; | 63 content::TestBrowserContext browser_context_; |
59 | 64 |
60 DISALLOW_COPY_AND_ASSIGN(GuestViewManagerTest); | 65 DISALLOW_COPY_AND_ASSIGN(GuestViewManagerTest); |
61 }; | 66 }; |
62 | 67 |
63 } // namespace | 68 } // namespace |
64 | 69 |
65 TEST_F(GuestViewManagerTest, AddRemove) { | 70 TEST_F(GuestViewManagerTest, AddRemove) { |
66 content::TestBrowserContext browser_context; | 71 content::TestBrowserContext browser_context; |
| 72 scoped_ptr<GuestViewManagerDelegate> delegate( |
| 73 new ExtensionsGuestViewManagerDelegate(&browser_context)); |
67 scoped_ptr<guestview::TestGuestViewManager> manager( | 74 scoped_ptr<guestview::TestGuestViewManager> manager( |
68 new guestview::TestGuestViewManager(&browser_context)); | 75 new guestview::TestGuestViewManager(&browser_context, delegate.Pass())); |
69 | 76 |
70 scoped_ptr<WebContents> web_contents1(CreateWebContents()); | 77 scoped_ptr<WebContents> web_contents1(CreateWebContents()); |
71 scoped_ptr<WebContents> web_contents2(CreateWebContents()); | 78 scoped_ptr<WebContents> web_contents2(CreateWebContents()); |
72 scoped_ptr<WebContents> web_contents3(CreateWebContents()); | 79 scoped_ptr<WebContents> web_contents3(CreateWebContents()); |
73 | 80 |
74 EXPECT_EQ(0, manager->last_instance_id_removed_for_testing()); | 81 EXPECT_EQ(0, manager->last_instance_id_removed_for_testing()); |
75 | 82 |
76 EXPECT_TRUE(manager->CanUseGuestInstanceID(1)); | 83 EXPECT_TRUE(manager->CanUseGuestInstanceID(1)); |
77 EXPECT_TRUE(manager->CanUseGuestInstanceID(2)); | 84 EXPECT_TRUE(manager->CanUseGuestInstanceID(2)); |
78 EXPECT_TRUE(manager->CanUseGuestInstanceID(3)); | 85 EXPECT_TRUE(manager->CanUseGuestInstanceID(3)); |
(...skipping 21 matching lines...) Expand all Loading... |
100 EXPECT_EQ(3, manager->last_instance_id_removed_for_testing()); | 107 EXPECT_EQ(3, manager->last_instance_id_removed_for_testing()); |
101 | 108 |
102 EXPECT_FALSE(manager->CanUseGuestInstanceID(1)); | 109 EXPECT_FALSE(manager->CanUseGuestInstanceID(1)); |
103 EXPECT_FALSE(manager->CanUseGuestInstanceID(2)); | 110 EXPECT_FALSE(manager->CanUseGuestInstanceID(2)); |
104 EXPECT_FALSE(manager->CanUseGuestInstanceID(3)); | 111 EXPECT_FALSE(manager->CanUseGuestInstanceID(3)); |
105 | 112 |
106 EXPECT_EQ(0u, manager->GetRemovedInstanceIdSize()); | 113 EXPECT_EQ(0u, manager->GetRemovedInstanceIdSize()); |
107 } | 114 } |
108 | 115 |
109 } // namespace extensions | 116 } // namespace extensions |
OLD | NEW |