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

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

Issue 1782053004: Change how the quota system computes the total poolsize for temporary storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 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
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "chrome/browser/extensions/extension_apitest.h" 12 #include "chrome/browser/extensions/extension_apitest.h"
13 #include "chrome/browser/sync_file_system/file_status_observer.h" 13 #include "chrome/browser/sync_file_system/file_status_observer.h"
14 #include "chrome/browser/sync_file_system/local_change_processor.h" 14 #include "chrome/browser/sync_file_system/local_change_processor.h"
15 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" 15 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h"
16 #include "chrome/browser/sync_file_system/sync_file_system_service.h" 16 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
17 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h" 17 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
18 #include "chrome/browser/sync_file_system/sync_status_code.h" 18 #include "chrome/browser/sync_file_system/sync_status_code.h"
19 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 19 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
20 #include "chrome/test/base/test_switches.h" 20 #include "chrome/test/base/test_switches.h"
21 #include "content/public/browser/storage_partition.h"
21 #include "extensions/browser/extension_function.h" 22 #include "extensions/browser/extension_function.h"
22 #include "storage/browser/fileapi/file_system_url.h" 23 #include "storage/browser/fileapi/file_system_url.h"
23 #include "storage/browser/quota/quota_manager.h" 24 #include "storage/browser/quota/quota_manager.h"
24 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 27
27 using ::testing::_; 28 using ::testing::_;
28 using ::testing::Eq; 29 using ::testing::Eq;
29 using ::testing::Ne; 30 using ::testing::Ne;
30 using ::testing::Property; 31 using ::testing::Property;
31 using ::testing::Return; 32 using ::testing::Return;
32 using storage::FileSystemURL; 33 using storage::FileSystemURL;
33 using sync_file_system::MockRemoteFileSyncService; 34 using sync_file_system::MockRemoteFileSyncService;
34 using sync_file_system::RemoteFileSyncService; 35 using sync_file_system::RemoteFileSyncService;
35 using sync_file_system::SyncFileSystemServiceFactory; 36 using sync_file_system::SyncFileSystemServiceFactory;
36 37
37 namespace { 38 namespace {
38 39
39 class SyncFileSystemApiTest : public ExtensionApiTest { 40 class SyncFileSystemApiTest : public ExtensionApiTest {
40 public: 41 public:
41 SyncFileSystemApiTest() 42 SyncFileSystemApiTest()
42 : mock_remote_service_(NULL), 43 : mock_remote_service_(NULL),
43 real_minimum_preserved_space_(0), 44 real_minimum_preserved_space_(0),
44 real_default_quota_(0) {} 45 real_default_quota_(0) {}
45 46
46 void SetUpInProcessBrowserTestFixture() override { 47 void SetUpInProcessBrowserTestFixture() override {
47 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 48 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
48 49
49 real_minimum_preserved_space_ =
50 storage::QuotaManager::kMinimumPreserveForSystem;
51 storage::QuotaManager::kMinimumPreserveForSystem = 0;
52
53 // TODO(calvinlo): Update test code after default quota is made const 50 // TODO(calvinlo): Update test code after default quota is made const
54 // (http://crbug.com/155488). 51 // (http://crbug.com/155488).
55 real_default_quota_ = 52 real_default_quota_ =
56 storage::QuotaManager::kSyncableStorageDefaultHostQuota; 53 storage::QuotaManager::kSyncableStorageDefaultHostQuota;
57 storage::QuotaManager::kSyncableStorageDefaultHostQuota = 123456; 54 storage::QuotaManager::kSyncableStorageDefaultHostQuota = 123456;
58 } 55 }
59 56
60 void TearDownInProcessBrowserTestFixture() override { 57 void TearDownInProcessBrowserTestFixture() override {
61 storage::QuotaManager::kMinimumPreserveForSystem =
62 real_minimum_preserved_space_;
63 storage::QuotaManager::kSyncableStorageDefaultHostQuota = 58 storage::QuotaManager::kSyncableStorageDefaultHostQuota =
64 real_default_quota_; 59 real_default_quota_;
65 ExtensionApiTest::TearDownInProcessBrowserTestFixture(); 60 ExtensionApiTest::TearDownInProcessBrowserTestFixture();
66 } 61 }
67 62
68 void SetUpOnMainThread() override { 63 void SetUpOnMainThread() override {
69 // Must happen after the browser process is created because instantiating 64 // Must happen after the browser process is created because instantiating
70 // the factory will instantiate ExtensionSystemFactory which depends on 65 // the factory will instantiate ExtensionSystemFactory which depends on
71 // ExtensionsBrowserClient setup in BrowserProcessImpl. 66 // ExtensionsBrowserClient setup in BrowserProcessImpl.
72 mock_remote_service_ = new ::testing::NiceMock<MockRemoteFileSyncService>; 67 mock_remote_service_ = new ::testing::NiceMock<MockRemoteFileSyncService>;
73 SyncFileSystemServiceFactory::GetInstance()->set_mock_remote_file_service( 68 SyncFileSystemServiceFactory::GetInstance()->set_mock_remote_file_service(
74 std::unique_ptr<RemoteFileSyncService>(mock_remote_service_)); 69 std::unique_ptr<RemoteFileSyncService>(mock_remote_service_));
75 ExtensionApiTest::SetUpOnMainThread(); 70 ExtensionApiTest::SetUpOnMainThread();
71
72 content::BrowserContext* context = browser()->profile();
73 const int kMeg = 1000 * 1024;
cmumford 2016/10/25 20:30:54 I can see 1024*1024, or 1000*1000, but why 1000*10
michaeln 2016/10/26 21:47:53 Done.
74 storage::TemporaryStorageConfiguration config;
75 config.pool_size = 25 * kMeg;
76 config.per_host_quota = 5 * kMeg;
77 config.must_remain_available = 0;
78 config.refresh_interval = base::TimeDelta::Max();
79 content::BrowserContext::GetDefaultStoragePartition(context)->
80 GetQuotaManager()->SetTemporaryStorageConfiguration(config);
76 } 81 }
77 82
78 ::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service() { 83 ::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service() {
79 return mock_remote_service_; 84 return mock_remote_service_;
80 } 85 }
81 86
82 private: 87 private:
83 ::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service_; 88 ::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service_;
84 int64_t real_minimum_preserved_space_; 89 int64_t real_minimum_preserved_space_;
85 int64_t real_default_quota_; 90 int64_t real_default_quota_;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/conflict_resolution_policy")) 211 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/conflict_resolution_policy"))
207 << message_; 212 << message_;
208 } 213 }
209 214
210 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetServiceStatus) { 215 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetServiceStatus) {
211 mock_remote_service()->SetServiceState( 216 mock_remote_service()->SetServiceState(
212 sync_file_system::REMOTE_SERVICE_AUTHENTICATION_REQUIRED); 217 sync_file_system::REMOTE_SERVICE_AUTHENTICATION_REQUIRED);
213 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/get_service_status")) 218 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/get_service_status"))
214 << message_; 219 << message_;
215 } 220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698