Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: extensions/browser/guest_view/guest_view_manager_unittest.cc

Issue 464533002: Move guest_view to extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Spacing are fixed. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/guest_view/guest_view_manager_factory.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/guest_view/guest_view_manager.h" 5 #include "extensions/browser/guest_view/guest_view_manager.h"
6 6
7 #include "chrome/test/base/testing_profile.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_thread_bundle.h" 9 #include "content/public/test/test_browser_thread_bundle.h"
9 #include "content/public/test/web_contents_tester.h" 10 #include "content/public/test/web_contents_tester.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "extensions/browser/extensions_test.h"
11 12
12 using content::WebContents; 13 using content::WebContents;
13 using content::WebContentsTester; 14 using content::WebContentsTester;
14 15
16 namespace extensions {
17
15 namespace guestview { 18 namespace guestview {
16 19
17 // This class allows us to access some private variables in 20 // This class allows us to access some private variables in
18 // GuestViewManager. 21 // GuestViewManager.
19 class TestGuestViewManager : public GuestViewManager { 22 class TestGuestViewManager : public GuestViewManager {
20 public: 23 public:
21 explicit TestGuestViewManager(content::BrowserContext* context) 24 explicit TestGuestViewManager(content::BrowserContext* context)
22 : GuestViewManager(context) {} 25 : GuestViewManager(context) {}
23 26
24 int last_instance_id_removed_for_testing() { 27 int last_instance_id_removed_for_testing() {
25 return last_instance_id_removed_; 28 return last_instance_id_removed_;
26 } 29 }
27 30
28 size_t GetRemovedInstanceIdSize() { return removed_instance_ids_.size(); } 31 size_t GetRemovedInstanceIdSize() { return removed_instance_ids_.size(); }
29 32
30 private: 33 private:
31 using GuestViewManager::last_instance_id_removed_; 34 using GuestViewManager::last_instance_id_removed_;
32 using GuestViewManager::removed_instance_ids_; 35 using GuestViewManager::removed_instance_ids_;
33 36
34 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManager); 37 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManager);
35 }; 38 };
36 39
37 } // namespace guestview 40 } // namespace guestview
38 41
39 namespace { 42 namespace {
40 43
41 class GuestViewManagerTest : public testing::Test { 44 class GuestViewManagerTest : public extensions::ExtensionsTest {
42 public: 45 public:
43 GuestViewManagerTest() {} 46 GuestViewManagerTest() :
47 notification_service_(content::NotificationService::Create()) {}
44 virtual ~GuestViewManagerTest() {} 48 virtual ~GuestViewManagerTest() {}
45 49
46 scoped_ptr<WebContents> CreateWebContents() { 50 scoped_ptr<WebContents> CreateWebContents() {
47 return scoped_ptr<WebContents>( 51 return scoped_ptr<WebContents>(
48 WebContentsTester::CreateTestWebContents(&profile_, NULL)); 52 WebContentsTester::CreateTestWebContents(&profile_, NULL));
49 } 53 }
50 54
51 private: 55 private:
56 scoped_ptr<content::NotificationService> notification_service_;
52 content::TestBrowserThreadBundle thread_bundle_; 57 content::TestBrowserThreadBundle thread_bundle_;
53 TestingProfile profile_; 58 content::TestBrowserContext profile_;
Ken Rockot(use gerrit already) 2014/08/11 21:25:00 nit: Rename profile_ to browser_context_?
Xi Han 2014/08/11 21:38:11 Done.
54 59
55 DISALLOW_COPY_AND_ASSIGN(GuestViewManagerTest); 60 DISALLOW_COPY_AND_ASSIGN(GuestViewManagerTest);
56 }; 61 };
57 62
58 } // namespace 63 } // namespace
59 64
60 TEST_F(GuestViewManagerTest, AddRemove) { 65 TEST_F(GuestViewManagerTest, AddRemove) {
61 TestingProfile profile; 66 content::TestBrowserContext profile;
Ken Rockot(use gerrit already) 2014/08/11 21:25:00 nit: Rename profile -> browser_context?
Xi Han 2014/08/11 21:38:11 Done.
62 scoped_ptr<guestview::TestGuestViewManager> manager( 67 scoped_ptr<guestview::TestGuestViewManager> manager(
63 new guestview::TestGuestViewManager(&profile)); 68 new guestview::TestGuestViewManager(&profile));
64 69
65 scoped_ptr<WebContents> web_contents1(CreateWebContents()); 70 scoped_ptr<WebContents> web_contents1(CreateWebContents());
66 scoped_ptr<WebContents> web_contents2(CreateWebContents()); 71 scoped_ptr<WebContents> web_contents2(CreateWebContents());
67 scoped_ptr<WebContents> web_contents3(CreateWebContents()); 72 scoped_ptr<WebContents> web_contents3(CreateWebContents());
68 73
69 EXPECT_EQ(0, manager->last_instance_id_removed_for_testing()); 74 EXPECT_EQ(0, manager->last_instance_id_removed_for_testing());
70 75
71 EXPECT_TRUE(manager->CanUseGuestInstanceID(1)); 76 EXPECT_TRUE(manager->CanUseGuestInstanceID(1));
(...skipping 21 matching lines...) Expand all
93 EXPECT_EQ(2, manager->last_instance_id_removed_for_testing()); 98 EXPECT_EQ(2, manager->last_instance_id_removed_for_testing());
94 manager->RemoveGuest(3); 99 manager->RemoveGuest(3);
95 EXPECT_EQ(3, manager->last_instance_id_removed_for_testing()); 100 EXPECT_EQ(3, manager->last_instance_id_removed_for_testing());
96 101
97 EXPECT_FALSE(manager->CanUseGuestInstanceID(1)); 102 EXPECT_FALSE(manager->CanUseGuestInstanceID(1));
98 EXPECT_FALSE(manager->CanUseGuestInstanceID(2)); 103 EXPECT_FALSE(manager->CanUseGuestInstanceID(2));
99 EXPECT_FALSE(manager->CanUseGuestInstanceID(3)); 104 EXPECT_FALSE(manager->CanUseGuestInstanceID(3));
100 105
101 EXPECT_EQ(0u, manager->GetRemovedInstanceIdSize()); 106 EXPECT_EQ(0u, manager->GetRemovedInstanceIdSize());
102 } 107 }
108
109 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/guest_view_manager_factory.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698