OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
7 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 7 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "content/public/browser/notification_service.h" | 9 #include "content/public/browser/notification_service.h" |
10 #include "content/public/browser/notification_source.h" | 10 #include "content/public/browser/notification_source.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 MOCK_METHOD0(GetOffTheRecordProfile, Profile*()); | 22 MOCK_METHOD0(GetOffTheRecordProfile, Profile*()); |
23 MOCK_METHOD0(HasOffTheRecordProfile, bool()); | 23 MOCK_METHOD0(HasOffTheRecordProfile, bool()); |
24 }; | 24 }; |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 class TestTabModel : public TabModel { | 27 class TestTabModel : public TabModel { |
28 public: | 28 public: |
29 explicit TestTabModel(Profile* profile) | 29 explicit TestTabModel(Profile* profile) |
30 : TabModel(profile) {} | 30 : TabModel(profile) {} |
31 | 31 |
32 virtual int GetTabCount() const OVERRIDE { return 0; } | 32 virtual int GetTabCount() const override { return 0; } |
33 virtual int GetActiveIndex() const OVERRIDE { return 0; } | 33 virtual int GetActiveIndex() const override { return 0; } |
34 virtual content::WebContents* GetWebContentsAt(int index) const OVERRIDE { | 34 virtual content::WebContents* GetWebContentsAt(int index) const override { |
35 return NULL; | 35 return NULL; |
36 } | 36 } |
37 virtual void CreateTab(content::WebContents* web_contents, | 37 virtual void CreateTab(content::WebContents* web_contents, |
38 int parent_tab_id) OVERRIDE {} | 38 int parent_tab_id) override {} |
39 virtual content::WebContents* CreateNewTabForDevTools( | 39 virtual content::WebContents* CreateNewTabForDevTools( |
40 const GURL& url) OVERRIDE { | 40 const GURL& url) override { |
41 return NULL; | 41 return NULL; |
42 } | 42 } |
43 virtual bool IsSessionRestoreInProgress() const OVERRIDE { return false; } | 43 virtual bool IsSessionRestoreInProgress() const override { return false; } |
44 virtual TabAndroid* GetTabAt(int index) const OVERRIDE { | 44 virtual TabAndroid* GetTabAt(int index) const override { |
45 return NULL; | 45 return NULL; |
46 } | 46 } |
47 virtual void SetActiveIndex(int index) OVERRIDE {} | 47 virtual void SetActiveIndex(int index) override {} |
48 virtual void CloseTabAt(int index) OVERRIDE {} | 48 virtual void CloseTabAt(int index) override {} |
49 }; | 49 }; |
50 | 50 |
51 TEST_F(TabModelTest, TestProfileHandling) { | 51 TEST_F(TabModelTest, TestProfileHandling) { |
52 // Construct TabModel with standard Profile. | 52 // Construct TabModel with standard Profile. |
53 TestingProfile testing_profile; | 53 TestingProfile testing_profile; |
54 TestTabModel tab_model(&testing_profile); | 54 TestTabModel tab_model(&testing_profile); |
55 | 55 |
56 // Verify TabModel has the correct profile and profile type. | 56 // Verify TabModel has the correct profile and profile type. |
57 EXPECT_EQ(&testing_profile, tab_model.GetProfile()); | 57 EXPECT_EQ(&testing_profile, tab_model.GetProfile()); |
58 EXPECT_FALSE(tab_model.IsOffTheRecord()); | 58 EXPECT_FALSE(tab_model.IsOffTheRecord()); |
(...skipping 19 matching lines...) Expand all Loading... |
78 EXPECT_EQ(&testing_profile, tab_model.GetProfile()); | 78 EXPECT_EQ(&testing_profile, tab_model.GetProfile()); |
79 EXPECT_TRUE(tab_model.IsOffTheRecord()); | 79 EXPECT_TRUE(tab_model.IsOffTheRecord()); |
80 | 80 |
81 // Notify profile is being destroyed and verify pointer is cleared. | 81 // Notify profile is being destroyed and verify pointer is cleared. |
82 content::NotificationService::current()->Notify( | 82 content::NotificationService::current()->Notify( |
83 chrome::NOTIFICATION_PROFILE_DESTROYED, | 83 chrome::NOTIFICATION_PROFILE_DESTROYED, |
84 content::Source<Profile>(&testing_profile), | 84 content::Source<Profile>(&testing_profile), |
85 content::NotificationService::NoDetails()); | 85 content::NotificationService::NoDetails()); |
86 EXPECT_EQ(NULL, tab_model.GetProfile()); | 86 EXPECT_EQ(NULL, tab_model.GetProfile()); |
87 } | 87 } |
OLD | NEW |