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/ui/android/tab_model/tab_model.h" | 5 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
6 #include "chrome/common/chrome_notification_types.h" | 6 #include "chrome/common/chrome_notification_types.h" |
7 #include "chrome/test/base/testing_profile.h" | 7 #include "chrome/test/base/testing_profile.h" |
8 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
9 #include "content/public/browser/notification_source.h" | 9 #include "content/public/browser/notification_source.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class TestTabModel : public TabModel { | 26 class TestTabModel : public TabModel { |
27 public: | 27 public: |
28 explicit TestTabModel(Profile* profile) | 28 explicit TestTabModel(Profile* profile) |
29 : TabModel(profile) {} | 29 : TabModel(profile) {} |
30 | 30 |
31 virtual int GetTabCount() const OVERRIDE { return 0; } | 31 virtual int GetTabCount() const OVERRIDE { return 0; } |
32 virtual int GetActiveIndex() const OVERRIDE { return 0; } | 32 virtual int GetActiveIndex() const OVERRIDE { return 0; } |
33 virtual content::WebContents* GetWebContentsAt(int index) const OVERRIDE { | 33 virtual content::WebContents* GetWebContentsAt(int index) const OVERRIDE { |
34 return NULL; | 34 return NULL; |
35 } | 35 } |
36 virtual SessionID::id_type GetTabIdAt(int index) const OVERRIDE { return 0; } | |
37 virtual void CreateTab(content::WebContents* web_contents) OVERRIDE {} | 36 virtual void CreateTab(content::WebContents* web_contents) OVERRIDE {} |
38 virtual bool IsSessionRestoreInProgress() const OVERRIDE { return false; } | 37 virtual bool IsSessionRestoreInProgress() const OVERRIDE { return false; } |
39 virtual void OpenClearBrowsingData() const OVERRIDE {} | 38 virtual void OpenClearBrowsingData() const OVERRIDE {} |
| 39 virtual browser_sync::SyncedTabDelegate* GetTabAt(int index) const OVERRIDE { |
| 40 return NULL; |
| 41 } |
| 42 |
40 }; | 43 }; |
41 | 44 |
42 TEST_F(TabModelTest, TestProfileHandling) { | 45 TEST_F(TabModelTest, TestProfileHandling) { |
43 // Construct TabModel with standard Profile. | 46 // Construct TabModel with standard Profile. |
44 TestingProfile testing_profile; | 47 TestingProfile testing_profile; |
45 TestTabModel tab_model(&testing_profile); | 48 TestTabModel tab_model(&testing_profile); |
46 | 49 |
47 // Verify TabModel has the correct profile and profile type. | 50 // Verify TabModel has the correct profile and profile type. |
48 EXPECT_EQ(&testing_profile, tab_model.GetProfile()); | 51 EXPECT_EQ(&testing_profile, tab_model.GetProfile()); |
49 EXPECT_FALSE(tab_model.IsOffTheRecord()); | 52 EXPECT_FALSE(tab_model.IsOffTheRecord()); |
(...skipping 19 matching lines...) Expand all Loading... |
69 EXPECT_EQ(&testing_profile, tab_model.GetProfile()); | 72 EXPECT_EQ(&testing_profile, tab_model.GetProfile()); |
70 EXPECT_TRUE(tab_model.IsOffTheRecord()); | 73 EXPECT_TRUE(tab_model.IsOffTheRecord()); |
71 | 74 |
72 // Notify profile is being destroyed and verify pointer is cleared. | 75 // Notify profile is being destroyed and verify pointer is cleared. |
73 content::NotificationService::current()->Notify( | 76 content::NotificationService::current()->Notify( |
74 chrome::NOTIFICATION_PROFILE_DESTROYED, | 77 chrome::NOTIFICATION_PROFILE_DESTROYED, |
75 content::Source<Profile>(&testing_profile), | 78 content::Source<Profile>(&testing_profile), |
76 content::NotificationService::NoDetails()); | 79 content::NotificationService::NoDetails()); |
77 EXPECT_EQ(NULL, tab_model.GetProfile()); | 80 EXPECT_EQ(NULL, tab_model.GetProfile()); |
78 } | 81 } |
OLD | NEW |