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

Side by Side Diff: chrome/browser/ui/android/tab_model/tab_model_unittest.cc

Issue 2923633002: Move identically named TestTabModel classes to anonymous namespace. (Closed)
Patch Set: Created 3 years, 6 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 | « chrome/browser/ui/android/tab_model/tab_model_list_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "content/public/test/test_browser_thread_bundle.h" 11 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 class TabModelTest : public testing::Test { 15 class TabModelTest : public testing::Test {
16 content::TestBrowserThreadBundle thread_bundle_; 16 content::TestBrowserThreadBundle thread_bundle_;
17 }; 17 };
18 18
19 namespace { 19 namespace {
20 class TabModelAndroidProfileMock : public TestingProfile { 20 class TabModelAndroidProfileMock : public TestingProfile {
21 public: 21 public:
22 TabModelAndroidProfileMock() {} 22 TabModelAndroidProfileMock() {}
23 virtual ~TabModelAndroidProfileMock() {} 23 virtual ~TabModelAndroidProfileMock() {}
24 24
25 MOCK_METHOD0(GetOffTheRecordProfile, Profile*()); 25 MOCK_METHOD0(GetOffTheRecordProfile, Profile*());
26 MOCK_METHOD0(HasOffTheRecordProfile, bool()); 26 MOCK_METHOD0(HasOffTheRecordProfile, bool());
27 }; 27 };
28 } // namespace
29 28
30 class TestTabModel : public TabModel { 29 class TestTabModel : public TabModel {
31 public: 30 public:
32 explicit TestTabModel(Profile* profile) : TabModel(profile, false) {} 31 explicit TestTabModel(Profile* profile) : TabModel(profile, false) {}
33 32
34 int GetTabCount() const override { return 0; } 33 int GetTabCount() const override { return 0; }
35 int GetActiveIndex() const override { return 0; } 34 int GetActiveIndex() const override { return 0; }
36 content::WebContents* GetWebContentsAt(int index) const override { 35 content::WebContents* GetWebContentsAt(int index) const override {
37 return NULL; 36 return NULL;
38 } 37 }
39 void CreateTab(TabAndroid* parent, 38 void CreateTab(TabAndroid* parent,
40 content::WebContents* web_contents, 39 content::WebContents* web_contents,
41 int parent_tab_id) override {} 40 int parent_tab_id) override {}
42 content::WebContents* CreateNewTabForDevTools(const GURL& url) override { 41 content::WebContents* CreateNewTabForDevTools(const GURL& url) override {
43 return NULL; 42 return NULL;
44 } 43 }
45 bool IsSessionRestoreInProgress() const override { return false; } 44 bool IsSessionRestoreInProgress() const override { return false; }
46 TabAndroid* GetTabAt(int index) const override { return NULL; } 45 TabAndroid* GetTabAt(int index) const override { return NULL; }
47 void SetActiveIndex(int index) override {} 46 void SetActiveIndex(int index) override {}
48 void CloseTabAt(int index) override {} 47 void CloseTabAt(int index) override {}
49 }; 48 };
49 } // namespace
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());
59 59
(...skipping 18 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/tab_model/tab_model_list_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698