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 "components/guest_view/browser/guest_view_manager.h" |
6 | 6 #include "components/guest_view/browser/guest_view_manager_delegate.h" |
| 7 #include "components/guest_view/browser/test_guest_view_manager.h" |
7 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
8 #include "content/public/test/test_browser_context.h" | 9 #include "content/public/test/test_browser_context.h" |
9 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
10 #include "content/public/test/web_contents_tester.h" | 11 #include "content/public/test/web_contents_tester.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" | |
15 #include "extensions/browser/guest_view/test_guest_view_manager.h" | |
16 | 12 |
17 using content::WebContents; | 13 using content::WebContents; |
18 using content::WebContentsTester; | 14 using content::WebContentsTester; |
19 using guestview::GuestViewManagerDelegate; | |
20 | 15 |
21 namespace extensions { | 16 namespace guestview { |
22 | 17 |
23 namespace { | 18 namespace { |
24 | 19 |
25 class GuestViewManagerTest : public extensions::ExtensionsTest { | 20 class GuestViewManagerTest : public testing::Test { |
26 public: | 21 public: |
27 GuestViewManagerTest() : | 22 GuestViewManagerTest() : |
28 notification_service_(content::NotificationService::Create()) {} | 23 notification_service_(content::NotificationService::Create()) {} |
29 ~GuestViewManagerTest() override {} | 24 ~GuestViewManagerTest() override {} |
30 | 25 |
31 scoped_ptr<WebContents> CreateWebContents() { | 26 scoped_ptr<WebContents> CreateWebContents() { |
32 return scoped_ptr<WebContents>( | 27 return scoped_ptr<WebContents>( |
33 WebContentsTester::CreateTestWebContents(&browser_context_, NULL)); | 28 WebContentsTester::CreateTestWebContents(&browser_context_, NULL)); |
34 } | 29 } |
35 | 30 |
36 private: | 31 private: |
37 scoped_ptr<content::NotificationService> notification_service_; | 32 scoped_ptr<content::NotificationService> notification_service_; |
38 content::TestBrowserThreadBundle thread_bundle_; | 33 content::TestBrowserThreadBundle thread_bundle_; |
39 content::TestBrowserContext browser_context_; | 34 content::TestBrowserContext browser_context_; |
40 | 35 |
41 DISALLOW_COPY_AND_ASSIGN(GuestViewManagerTest); | 36 DISALLOW_COPY_AND_ASSIGN(GuestViewManagerTest); |
42 }; | 37 }; |
43 | 38 |
44 } // namespace | 39 } // namespace |
45 | 40 |
46 TEST_F(GuestViewManagerTest, AddRemove) { | 41 TEST_F(GuestViewManagerTest, AddRemove) { |
47 content::TestBrowserContext browser_context; | 42 content::TestBrowserContext browser_context; |
48 scoped_ptr<GuestViewManagerDelegate> delegate( | 43 scoped_ptr<GuestViewManagerDelegate> delegate( |
49 new ExtensionsGuestViewManagerDelegate(&browser_context)); | 44 new GuestViewManagerDelegate(&browser_context)); |
50 scoped_ptr<TestGuestViewManager> manager( | 45 scoped_ptr<TestGuestViewManager> manager( |
51 new extensions::TestGuestViewManager(&browser_context, delegate.Pass())); | 46 new extensions::TestGuestViewManager(&browser_context, delegate.Pass())); |
52 | 47 |
53 scoped_ptr<WebContents> web_contents1(CreateWebContents()); | 48 scoped_ptr<WebContents> web_contents1(CreateWebContents()); |
54 scoped_ptr<WebContents> web_contents2(CreateWebContents()); | 49 scoped_ptr<WebContents> web_contents2(CreateWebContents()); |
55 scoped_ptr<WebContents> web_contents3(CreateWebContents()); | 50 scoped_ptr<WebContents> web_contents3(CreateWebContents()); |
56 | 51 |
57 EXPECT_EQ(0, manager->last_instance_id_removed()); | 52 EXPECT_EQ(0, manager->last_instance_id_removed()); |
58 | 53 |
59 EXPECT_TRUE(manager->CanUseGuestInstanceID(1)); | 54 EXPECT_TRUE(manager->CanUseGuestInstanceID(1)); |
(...skipping 22 matching lines...) Expand all Loading... |
82 manager->RemoveGuest(3); | 77 manager->RemoveGuest(3); |
83 EXPECT_EQ(3, manager->last_instance_id_removed()); | 78 EXPECT_EQ(3, manager->last_instance_id_removed()); |
84 | 79 |
85 EXPECT_FALSE(manager->CanUseGuestInstanceID(1)); | 80 EXPECT_FALSE(manager->CanUseGuestInstanceID(1)); |
86 EXPECT_FALSE(manager->CanUseGuestInstanceID(2)); | 81 EXPECT_FALSE(manager->CanUseGuestInstanceID(2)); |
87 EXPECT_FALSE(manager->CanUseGuestInstanceID(3)); | 82 EXPECT_FALSE(manager->CanUseGuestInstanceID(3)); |
88 | 83 |
89 EXPECT_EQ(0, manager->GetNumRemovedInstanceIDs()); | 84 EXPECT_EQ(0, manager->GetNumRemovedInstanceIDs()); |
90 } | 85 } |
91 | 86 |
92 } // namespace extensions | 87 } // namespace guestview |
OLD | NEW |