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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_quota_helper_unittest.cc

Issue 1542413002: Switch to standard integer types in chrome/browser/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
11 #include "chrome/browser/browsing_data/browsing_data_quota_helper_impl.h" 15 #include "chrome/browser/browsing_data/browsing_data_quota_helper_impl.h"
12 #include "content/public/test/mock_storage_client.h" 16 #include "content/public/test/mock_storage_client.h"
13 #include "content/public/test/test_browser_thread.h" 17 #include "content/public/test/test_browser_thread.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "storage/browser/quota/quota_manager.h" 19 #include "storage/browser/quota/quota_manager.h"
16 #include "storage/browser/quota/quota_manager_proxy.h" 20 #include "storage/browser/quota/quota_manager_proxy.h"
17 21
18 using content::BrowserThread; 22 using content::BrowserThread;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 void RegisterClient(const MockOriginData* data, std::size_t data_len) { 68 void RegisterClient(const MockOriginData* data, std::size_t data_len) {
65 MockStorageClient* client = 69 MockStorageClient* client =
66 new MockStorageClient(quota_manager_->proxy(), 70 new MockStorageClient(quota_manager_->proxy(),
67 data, 71 data,
68 storage::QuotaClient::kFileSystem, 72 storage::QuotaClient::kFileSystem,
69 data_len); 73 data_len);
70 quota_manager_->proxy()->RegisterClient(client); 74 quota_manager_->proxy()->RegisterClient(client);
71 client->TouchAllOriginsAndNotify(); 75 client->TouchAllOriginsAndNotify();
72 } 76 }
73 77
74 void SetPersistentHostQuota(const std::string& host, int64 quota) { 78 void SetPersistentHostQuota(const std::string& host, int64_t quota) {
75 quota_ = -1; 79 quota_ = -1;
76 quota_manager_->SetPersistentHostQuota( 80 quota_manager_->SetPersistentHostQuota(
77 host, quota, 81 host, quota,
78 base::Bind(&BrowsingDataQuotaHelperTest::GotPersistentHostQuota, 82 base::Bind(&BrowsingDataQuotaHelperTest::GotPersistentHostQuota,
79 weak_factory_.GetWeakPtr())); 83 weak_factory_.GetWeakPtr()));
80 } 84 }
81 85
82 void GetPersistentHostQuota(const std::string& host) { 86 void GetPersistentHostQuota(const std::string& host) {
83 quota_ = -1; 87 quota_ = -1;
84 quota_manager_->GetPersistentHostQuota( 88 quota_manager_->GetPersistentHostQuota(
85 host, 89 host,
86 base::Bind(&BrowsingDataQuotaHelperTest::GotPersistentHostQuota, 90 base::Bind(&BrowsingDataQuotaHelperTest::GotPersistentHostQuota,
87 weak_factory_.GetWeakPtr())); 91 weak_factory_.GetWeakPtr()));
88 } 92 }
89 93
90 void GotPersistentHostQuota(storage::QuotaStatusCode status, int64 quota) { 94 void GotPersistentHostQuota(storage::QuotaStatusCode status, int64_t quota) {
91 EXPECT_EQ(storage::kQuotaStatusOk, status); 95 EXPECT_EQ(storage::kQuotaStatusOk, status);
92 quota_ = quota; 96 quota_ = quota;
93 } 97 }
94 98
95 void RevokeHostQuota(const std::string& host) { 99 void RevokeHostQuota(const std::string& host) {
96 helper_->RevokeHostQuota(host); 100 helper_->RevokeHostQuota(host);
97 } 101 }
98 102
99 int64 quota() { 103 int64_t quota() { return quota_; }
100 return quota_;
101 }
102 104
103 private: 105 private:
104 void FetchCompleted(const QuotaInfoArray& quota_info) { 106 void FetchCompleted(const QuotaInfoArray& quota_info) {
105 quota_info_ = quota_info; 107 quota_info_ = quota_info;
106 fetching_completed_ = true; 108 fetching_completed_ = true;
107 } 109 }
108 110
109 content::TestBrowserThreadBundle thread_bundle_; 111 content::TestBrowserThreadBundle thread_bundle_;
110 scoped_refptr<storage::QuotaManager> quota_manager_; 112 scoped_refptr<storage::QuotaManager> quota_manager_;
111 113
112 base::ScopedTempDir dir_; 114 base::ScopedTempDir dir_;
113 scoped_refptr<BrowsingDataQuotaHelper> helper_; 115 scoped_refptr<BrowsingDataQuotaHelper> helper_;
114 116
115 bool fetching_completed_ = true; 117 bool fetching_completed_ = true;
116 QuotaInfoArray quota_info_; 118 QuotaInfoArray quota_info_;
117 int64 quota_ = -1; 119 int64_t quota_ = -1;
118 base::WeakPtrFactory<BrowsingDataQuotaHelperTest> weak_factory_; 120 base::WeakPtrFactory<BrowsingDataQuotaHelperTest> weak_factory_;
119 121
120 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperTest); 122 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperTest);
121 }; 123 };
122 124
123 TEST_F(BrowsingDataQuotaHelperTest, Empty) { 125 TEST_F(BrowsingDataQuotaHelperTest, Empty) {
124 StartFetching(); 126 StartFetching();
125 base::MessageLoop::current()->RunUntilIdle(); 127 base::MessageLoop::current()->RunUntilIdle();
126 EXPECT_TRUE(fetching_completed()); 128 EXPECT_TRUE(fetching_completed());
127 EXPECT_TRUE(quota_info().empty()); 129 EXPECT_TRUE(quota_info().empty());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 base::MessageLoop::current()->RunUntilIdle(); 191 base::MessageLoop::current()->RunUntilIdle();
190 192
191 GetPersistentHostQuota(kHost1); 193 GetPersistentHostQuota(kHost1);
192 base::MessageLoop::current()->RunUntilIdle(); 194 base::MessageLoop::current()->RunUntilIdle();
193 EXPECT_EQ(0, quota()); 195 EXPECT_EQ(0, quota());
194 196
195 GetPersistentHostQuota(kHost2); 197 GetPersistentHostQuota(kHost2);
196 base::MessageLoop::current()->RunUntilIdle(); 198 base::MessageLoop::current()->RunUntilIdle();
197 EXPECT_EQ(10, quota()); 199 EXPECT_EQ(10, quota());
198 } 200 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_quota_helper_impl.cc ('k') | chrome/browser/browsing_data/browsing_data_remover.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698