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/chromeos/drive/drive_integration_service.h" | 5 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/drive/dummy_file_system.h" | 7 #include "chrome/browser/chromeos/drive/dummy_file_system.h" |
8 #include "chrome/browser/chromeos/drive/test_util.h" | |
9 #include "chrome/browser/drive/dummy_drive_service.h" | 8 #include "chrome/browser/drive/dummy_drive_service.h" |
10 #include "chrome/test/base/testing_browser_process.h" | 9 #include "chrome/test/base/testing_browser_process.h" |
11 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
12 #include "chrome/test/base/testing_profile_manager.h" | 11 #include "chrome/test/base/testing_profile_manager.h" |
13 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "content/public/test/test_utils.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace drive { | 16 namespace drive { |
17 | 17 |
18 namespace{ | 18 namespace{ |
19 const char kTestProfileName[] = "test-profile"; | 19 const char kTestProfileName[] = "test-profile"; |
20 } | 20 } |
21 | 21 |
22 class DriveIntegrationServiceTest : public testing::Test { | 22 class DriveIntegrationServiceTest : public testing::Test { |
23 public: | 23 public: |
(...skipping 16 matching lines...) Expand all Loading... |
40 TEST_F(DriveIntegrationServiceTest, InitializeAndShutdown) { | 40 TEST_F(DriveIntegrationServiceTest, InitializeAndShutdown) { |
41 scoped_ptr<DriveIntegrationService> integration_service( | 41 scoped_ptr<DriveIntegrationService> integration_service( |
42 new DriveIntegrationService( | 42 new DriveIntegrationService( |
43 profile_manager_.CreateTestingProfile(kTestProfileName), | 43 profile_manager_.CreateTestingProfile(kTestProfileName), |
44 NULL, | 44 NULL, |
45 new DummyDriveService, | 45 new DummyDriveService, |
46 std::string(), | 46 std::string(), |
47 base::FilePath(), | 47 base::FilePath(), |
48 new DummyFileSystem)); | 48 new DummyFileSystem)); |
49 integration_service->SetEnabled(true); | 49 integration_service->SetEnabled(true); |
50 test_util::RunBlockingPoolTask(); | 50 content::RunAllBlockingPoolTasksUntilIdle(); |
51 integration_service->Shutdown(); | 51 integration_service->Shutdown(); |
52 } | 52 } |
53 | 53 |
54 TEST_F(DriveIntegrationServiceTest, ServiceInstanceIdentity) { | 54 TEST_F(DriveIntegrationServiceTest, ServiceInstanceIdentity) { |
55 TestingProfile* user1 = profile_manager_.CreateTestingProfile("user1"); | 55 TestingProfile* user1 = profile_manager_.CreateTestingProfile("user1"); |
56 | 56 |
57 // Integration Service is created as a profile keyed service. | 57 // Integration Service is created as a profile keyed service. |
58 EXPECT_TRUE(DriveIntegrationServiceFactory::GetForProfile(user1)); | 58 EXPECT_TRUE(DriveIntegrationServiceFactory::GetForProfile(user1)); |
59 | 59 |
60 // Shares the same instance with the incognito mode profile. | 60 // Shares the same instance with the incognito mode profile. |
61 Profile* user1_incognito = user1->GetOffTheRecordProfile(); | 61 Profile* user1_incognito = user1->GetOffTheRecordProfile(); |
62 EXPECT_EQ(DriveIntegrationServiceFactory::GetForProfile(user1), | 62 EXPECT_EQ(DriveIntegrationServiceFactory::GetForProfile(user1), |
63 DriveIntegrationServiceFactory::GetForProfile(user1_incognito)); | 63 DriveIntegrationServiceFactory::GetForProfile(user1_incognito)); |
64 | 64 |
65 // For different profiles, different services are running. | 65 // For different profiles, different services are running. |
66 TestingProfile* user2 = profile_manager_.CreateTestingProfile("user2"); | 66 TestingProfile* user2 = profile_manager_.CreateTestingProfile("user2"); |
67 EXPECT_NE(DriveIntegrationServiceFactory::GetForProfile(user1), | 67 EXPECT_NE(DriveIntegrationServiceFactory::GetForProfile(user1), |
68 DriveIntegrationServiceFactory::GetForProfile(user2)); | 68 DriveIntegrationServiceFactory::GetForProfile(user2)); |
69 } | 69 } |
70 | 70 |
71 } // namespace drive | 71 } // namespace drive |
OLD | NEW |