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

Side by Side Diff: chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc

Issue 118043003: Fix app_shell shutdown crash due to BrowserContextKeyedServices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ScopedFactoryForTest (shutdown_crash) Created 6 years, 11 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chrome/browser/extensions/event_names.h" 9 #include "chrome/browser/extensions/event_names.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 19 matching lines...) Expand all
30 using ::testing::Return; 30 using ::testing::Return;
31 using fileapi::FileSystemURL; 31 using fileapi::FileSystemURL;
32 using sync_file_system::MockRemoteFileSyncService; 32 using sync_file_system::MockRemoteFileSyncService;
33 using sync_file_system::RemoteFileSyncService; 33 using sync_file_system::RemoteFileSyncService;
34 using sync_file_system::SyncFileSystemServiceFactory; 34 using sync_file_system::SyncFileSystemServiceFactory;
35 35
36 namespace { 36 namespace {
37 37
38 class SyncFileSystemApiTest : public ExtensionApiTest { 38 class SyncFileSystemApiTest : public ExtensionApiTest {
39 public: 39 public:
40 SyncFileSystemApiTest() {} 40 SyncFileSystemApiTest()
41 : mock_remote_service_(NULL), real_default_quota_(0) {}
41 42
42 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 43 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
43 mock_remote_service_ = new ::testing::NiceMock<MockRemoteFileSyncService>;
44 SyncFileSystemServiceFactory::GetInstance()->set_mock_remote_file_service(
45 scoped_ptr<RemoteFileSyncService>(mock_remote_service_));
46
47 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 44 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
48 // TODO(calvinlo): Update test code after default quota is made const 45 // TODO(calvinlo): Update test code after default quota is made const
49 // (http://crbug.com/155488). 46 // (http://crbug.com/155488).
50 real_default_quota_ = quota::QuotaManager::kSyncableStorageDefaultHostQuota; 47 real_default_quota_ = quota::QuotaManager::kSyncableStorageDefaultHostQuota;
51 quota::QuotaManager::kSyncableStorageDefaultHostQuota = 123456; 48 quota::QuotaManager::kSyncableStorageDefaultHostQuota = 123456;
52 } 49 }
53 50
54 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { 51 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
55 quota::QuotaManager::kSyncableStorageDefaultHostQuota = real_default_quota_; 52 quota::QuotaManager::kSyncableStorageDefaultHostQuota = real_default_quota_;
56 ExtensionApiTest::TearDownInProcessBrowserTestFixture(); 53 ExtensionApiTest::TearDownInProcessBrowserTestFixture();
57 } 54 }
58 55
56 virtual void SetUpOnMainThread() OVERRIDE {
57 // Must happen after the browser process is created because instantiating
58 // the factory will instantiate ExtensionSystemFactory which depends on
59 // ExtensionsBrowserClient setup in BrowserProcessImpl.
60 mock_remote_service_ = new ::testing::NiceMock<MockRemoteFileSyncService>;
61 SyncFileSystemServiceFactory::GetInstance()->set_mock_remote_file_service(
62 scoped_ptr<RemoteFileSyncService>(mock_remote_service_));
63 ExtensionApiTest::SetUpOnMainThread();
64 }
65
59 ::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service() { 66 ::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service() {
60 return mock_remote_service_; 67 return mock_remote_service_;
61 } 68 }
62 69
63 private: 70 private:
64 ::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service_; 71 ::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service_;
65 int64 real_default_quota_; 72 int64 real_default_quota_;
66 }; 73 };
67 74
68 ACTION_P(NotifyOkStateAndCallback, mock_remote_service) { 75 ACTION_P(NotifyOkStateAndCallback, mock_remote_service) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/conflict_resolution_policy")) 203 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/conflict_resolution_policy"))
197 << message_; 204 << message_;
198 } 205 }
199 206
200 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetServiceStatus) { 207 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetServiceStatus) {
201 mock_remote_service()->SetServiceState( 208 mock_remote_service()->SetServiceState(
202 sync_file_system::REMOTE_SERVICE_AUTHENTICATION_REQUIRED); 209 sync_file_system::REMOTE_SERVICE_AUTHENTICATION_REQUIRED);
203 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/get_service_status")) 210 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/get_service_status"))
204 << message_; 211 << message_;
205 } 212 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698