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

Side by Side Diff: goopdate/package_cache_unittest.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 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
« no previous file with comments | « goopdate/package_cache_internal.h ('k') | goopdate/process_launcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2007-2009 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16 #include "omaha/base/app_util.h"
17 #include "omaha/base/error.h"
18 #include "omaha/base/file.h"
19 #include "omaha/base/path.h"
20 #include "omaha/base/string.h"
21 #include "omaha/base/utils.h"
22 #include "omaha/goopdate/package_cache.h"
23 #include "omaha/testing/unit_test.h"
24
25 namespace omaha {
26
27 class PackageCacheTest : public testing::Test {
28 protected:
29 typedef PackageCache::Key Key;
30
31 PackageCacheTest()
32 : cache_root_(GetUniqueTempDirectoryName()),
33 size_file1_(0),
34 size_file2_(0) {
35 EXPECT_FALSE(cache_root_.IsEmpty());
36
37 CString executable_path(app_util::GetCurrentModuleDirectory());
38
39 source_file1_ = ConcatenatePath(
40 executable_path,
41 _T("unittest_support\\download_cache_test\\")
42 _T("{89640431-FE64-4da8-9860-1A1085A60E13}\\gears-win32-opt.msi"));
43
44 hash_file1_ = _T("ImV9skETZqGFMjs32vbZTvzAYJU=");
45
46 size_file1_ = 870400;
47
48 source_file2_ = ConcatenatePath(
49 executable_path,
50 _T("unittest_support\\download_cache_test\\")
51 _T("{7101D597-3481-4971-AD23-455542964072}\\livelysetup.exe"));
52
53 hash_file2_ = _T("Igq6bYaeXFJCjH770knXyJ6V53s=");
54
55 size_file2_ = 479848;
56
57 EXPECT_TRUE(File::Exists(source_file1_));
58 EXPECT_TRUE(File::Exists(source_file2_));
59 }
60
61 virtual void SetUp() {
62 EXPECT_FALSE(String_EndsWith(cache_root_, _T("\\"), true));
63 EXPECT_HRESULT_SUCCEEDED(package_cache_.Initialize(cache_root_));
64 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAll());
65 }
66
67 virtual void TearDown() {
68 EXPECT_HRESULT_SUCCEEDED(DeleteDirectory(cache_root_));
69 }
70
71 HRESULT BuildCacheFileNameForKey(const Key& key, CString* filename) const {
72 return package_cache_.BuildCacheFileNameForKey(key, filename);
73 }
74
75 HRESULT ExpireCache(const Key& key) {
76 FILETIME expiration_time = package_cache_.GetCacheExpirationTime();
77
78 CString cached_file_name;
79 EXPECT_HRESULT_SUCCEEDED(BuildCacheFileNameForKey(key, &cached_file_name));
80
81 // Change file time a little big earlier than the expiration time.
82 ULARGE_INTEGER file_time = {0};
83 file_time.LowPart = expiration_time.dwLowDateTime;
84 file_time.HighPart = expiration_time.dwHighDateTime;
85 file_time.QuadPart -= 1;
86
87 expiration_time.dwLowDateTime = file_time.LowPart;
88 expiration_time.dwHighDateTime = file_time.HighPart;
89
90 return File::SetFileTime(cached_file_name,
91 &expiration_time,
92 &expiration_time,
93 &expiration_time);
94 }
95
96 void SetCacheSizeLimitMB(int limit_mb) {
97 package_cache_.cache_size_limit_bytes_ = 1024 * 1024 *
98 static_cast<uint64>(limit_mb);
99 }
100
101 void SetCacheTimeLimitDays(int limit_days) {
102 package_cache_.cache_time_limit_days_ = limit_days;
103 }
104
105 const CString cache_root_;
106 CString source_file1_;
107 CString hash_file1_;
108 uint64 size_file1_;
109
110 CString source_file2_;
111 CString hash_file2_;
112 uint64 size_file2_;
113
114 PackageCache package_cache_;
115 };
116
117 // Tests the members of key when the constructor arguments are empty strings.
118 TEST_F(PackageCacheTest, DefaultVersion) {
119 Key key(_T(""), _T(""), _T(""));
120 EXPECT_STREQ(_T(""), key.app_id());
121 EXPECT_STREQ(_T("0.0.0.0"), key.version());
122 EXPECT_STREQ(_T(""), key.package_name());
123 }
124
125 TEST_F(PackageCacheTest, Initialize) {
126 EXPECT_FALSE(package_cache_.cache_root().IsEmpty());
127 EXPECT_STREQ(cache_root_, package_cache_.cache_root());
128 EXPECT_EQ(0, package_cache_.Size());
129 }
130
131 TEST_F(PackageCacheTest, InitializeErrors) {
132 PackageCache package_cache;
133 EXPECT_EQ(E_INVALIDARG, package_cache.Initialize(NULL));
134 EXPECT_EQ(E_INVALIDARG, package_cache.Initialize(_T("")));
135 EXPECT_EQ(E_INVALIDARG, package_cache.Initialize(_T("foo")));
136 }
137
138 TEST_F(PackageCacheTest, BuildCacheFileName) {
139 CString actual;
140 EXPECT_HRESULT_SUCCEEDED(
141 BuildCacheFileNameForKey(Key(_T("1"), _T("2"), _T("3")), &actual));
142 CString expected = cache_root_ + _T("\\1\\2\\3");
143 EXPECT_STREQ(expected, actual);
144
145 EXPECT_HRESULT_SUCCEEDED(
146 BuildCacheFileNameForKey(Key(_T("1"), _T("2"), _T("3\\4")), &actual));
147 expected = cache_root_ + _T("\\1\\2\\3\\4");
148 EXPECT_STREQ(expected, actual);
149
150 EXPECT_EQ(E_INVALIDARG,
151 BuildCacheFileNameForKey(Key(_T("1"), _T("2"), _T("..\\3")),
152 &actual));
153 }
154
155 // Tests Put, Get, IsCached, and Purge calls.
156 TEST_F(PackageCacheTest, BasicTest) {
157 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAll());
158
159 Key key1(_T("app1"), _T("ver1"), _T("package1"));
160
161 // Check the file is not in the cache.
162 EXPECT_FALSE(package_cache_.IsCached(key1, hash_file1_));
163
164 // Cache one file.
165 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key1,
166 source_file1_,
167 hash_file1_));
168 EXPECT_EQ(size_file1_, package_cache_.Size());
169
170 // Check the file is in the cache.
171 EXPECT_TRUE(package_cache_.IsCached(key1, hash_file1_));
172
173 // Check the source file is not deleted after caching it.
174 EXPECT_TRUE(File::Exists(source_file1_));
175
176 // Get the package from the cache into a temporary file.
177 CString destination_file;
178 EXPECT_TRUE(::GetTempFileName(app_util::GetTempDir(), _T(""), 0,
179 CStrBuf(destination_file, MAX_PATH)));
180
181 // Get the file two times.
182 EXPECT_HRESULT_SUCCEEDED(package_cache_.Get(key1,
183 destination_file,
184 hash_file1_));
185 EXPECT_TRUE(File::Exists(destination_file));
186 EXPECT_HRESULT_SUCCEEDED(PackageCache::AuthenticateFile(destination_file,
187 hash_file1_));
188
189 EXPECT_HRESULT_SUCCEEDED(package_cache_.Get(key1,
190 destination_file,
191 hash_file1_));
192 EXPECT_TRUE(File::Exists(destination_file));
193 EXPECT_HRESULT_SUCCEEDED(PackageCache::AuthenticateFile(destination_file,
194 hash_file1_));
195
196 EXPECT_TRUE(::DeleteFile(destination_file));
197
198 // Cache another file.
199 Key key2(_T("app2"), _T("ver2"), _T("package2"));
200
201 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key2,
202 source_file2_,
203 hash_file2_));
204 EXPECT_EQ(size_file1_ + size_file2_, package_cache_.Size());
205 EXPECT_TRUE(package_cache_.IsCached(key2, hash_file2_));
206
207 // Cache the same file again. It should be idempotent.
208 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key2,
209 source_file2_,
210 hash_file2_));
211 EXPECT_EQ(size_file1_ + size_file2_, package_cache_.Size());
212
213 EXPECT_TRUE(package_cache_.IsCached(key2, hash_file2_));
214 EXPECT_TRUE(File::Exists(source_file2_));
215
216 EXPECT_HRESULT_SUCCEEDED(package_cache_.Purge(key1));
217 EXPECT_FALSE(package_cache_.IsCached(key1, hash_file1_));
218 EXPECT_EQ(size_file2_, package_cache_.Size());
219
220 EXPECT_HRESULT_SUCCEEDED(package_cache_.Purge(key2));
221 EXPECT_FALSE(package_cache_.IsCached(key2, hash_file2_));
222 EXPECT_EQ(0, package_cache_.Size());
223
224 // Try getting a purged files.
225 EXPECT_HRESULT_FAILED(package_cache_.Get(key1,
226 destination_file,
227 hash_file1_));
228 EXPECT_FALSE(File::Exists(destination_file));
229
230 EXPECT_HRESULT_FAILED(package_cache_.Get(key2,
231 destination_file,
232 hash_file2_));
233 EXPECT_FALSE(File::Exists(destination_file));
234 }
235
236 TEST_F(PackageCacheTest, PutBadHashTest) {
237 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAll());
238
239 Key key1(_T("app1"), _T("ver1"), _T("package1"));
240
241 // Check the file is not in the cache.
242 EXPECT_FALSE(package_cache_.IsCached(key1, hash_file1_));
243
244 // Try caching one file when the hash is not correct.
245 const CString bad_hash = _T("JmV9skETZqGFMjs32vbZTvzAYJU=");
246 EXPECT_EQ(SIGS_E_INVALID_SIGNATURE, package_cache_.Put(key1,
247 source_file1_,
248 bad_hash));
249 // Check the file is not the cache.
250 EXPECT_FALSE(package_cache_.IsCached(key1, hash_file1_));
251 }
252
253 // The key must include the app id, version, and package name for Put and Get
254 // operations. If the version is not provided, "0.0.0.0" is used internally.
255 TEST_F(PackageCacheTest, BadKeyTest) {
256 Key key_empty_app(_T(""), _T("b"), _T("c"));
257 Key key_empty_name(_T("a"), _T("b"), _T(""));
258
259 EXPECT_EQ(E_INVALIDARG, package_cache_.Get(key_empty_app, _T("a"), _T("b")));
260 EXPECT_EQ(E_INVALIDARG, package_cache_.Get(key_empty_name, _T("a"), _T("b")));
261
262 EXPECT_EQ(E_INVALIDARG, package_cache_.Put(key_empty_app, _T("a"), _T("b")));
263 EXPECT_EQ(E_INVALIDARG, package_cache_.Put(key_empty_name, _T("a"), _T("b")));
264 }
265
266 TEST_F(PackageCacheTest, PurgeVersionTest) {
267 // Cache two files for two versions of the same app.
268 Key key11(_T("app1"), _T("ver1"), _T("package1"));
269 Key key12(_T("app1"), _T("ver1"), _T("package2"));
270 Key key21(_T("app1"), _T("ver2"), _T("package1"));
271 Key key22(_T("app1"), _T("ver2"), _T("package2"));
272
273 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key11,
274 source_file1_,
275 hash_file1_));
276 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key12,
277 source_file2_,
278 hash_file2_));
279 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key21,
280 source_file1_,
281 hash_file1_));
282 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key22,
283 source_file2_,
284 hash_file2_));
285
286 EXPECT_TRUE(package_cache_.IsCached(key11, hash_file1_));
287 EXPECT_TRUE(package_cache_.IsCached(key12, hash_file2_));
288 EXPECT_TRUE(package_cache_.IsCached(key21, hash_file1_));
289 EXPECT_TRUE(package_cache_.IsCached(key22, hash_file2_));
290
291 EXPECT_EQ(2 * (size_file1_ + size_file2_), package_cache_.Size());
292
293 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeVersion(_T("app1"), _T("ver1")));
294
295 EXPECT_FALSE(package_cache_.IsCached(key11, hash_file1_));
296 EXPECT_FALSE(package_cache_.IsCached(key12, hash_file2_));
297 EXPECT_TRUE(package_cache_.IsCached(key21, hash_file1_));
298 EXPECT_TRUE(package_cache_.IsCached(key22, hash_file2_));
299
300 EXPECT_EQ(size_file1_ + size_file2_, package_cache_.Size());
301
302 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeVersion(_T("app1"), _T("ver2")));
303
304 EXPECT_FALSE(package_cache_.IsCached(key11, hash_file1_));
305 EXPECT_FALSE(package_cache_.IsCached(key12, hash_file2_));
306 EXPECT_FALSE(package_cache_.IsCached(key21, hash_file1_));
307 EXPECT_FALSE(package_cache_.IsCached(key22, hash_file2_));
308
309 EXPECT_EQ(0, package_cache_.Size());
310 }
311
312 TEST_F(PackageCacheTest, PurgeAppTest) {
313 // Cache two files for two apps.
314 Key key11(_T("app1"), _T("ver1"), _T("package1"));
315 Key key12(_T("app1"), _T("ver1"), _T("package2"));
316 Key key21(_T("app2"), _T("ver2"), _T("package1"));
317 Key key22(_T("app2"), _T("ver2"), _T("package2"));
318
319 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key11,
320 source_file1_,
321 hash_file1_));
322 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key12,
323 source_file2_,
324 hash_file2_));
325 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key21,
326 source_file1_,
327 hash_file1_));
328 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key22,
329 source_file2_,
330 hash_file2_));
331
332 EXPECT_TRUE(package_cache_.IsCached(key11, hash_file1_));
333 EXPECT_TRUE(package_cache_.IsCached(key12, hash_file2_));
334 EXPECT_TRUE(package_cache_.IsCached(key21, hash_file1_));
335 EXPECT_TRUE(package_cache_.IsCached(key22, hash_file2_));
336
337 EXPECT_EQ(2 * (size_file1_ + size_file2_), package_cache_.Size());
338
339 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeApp(_T("app1")));
340
341 EXPECT_FALSE(package_cache_.IsCached(key11, hash_file1_));
342 EXPECT_FALSE(package_cache_.IsCached(key12, hash_file2_));
343 EXPECT_TRUE(package_cache_.IsCached(key21, hash_file1_));
344 EXPECT_TRUE(package_cache_.IsCached(key22, hash_file2_));
345
346 EXPECT_EQ(size_file1_ + size_file2_, package_cache_.Size());
347
348 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeApp(_T("app2")));
349
350 EXPECT_FALSE(package_cache_.IsCached(key11, hash_file1_));
351 EXPECT_FALSE(package_cache_.IsCached(key12, hash_file2_));
352 EXPECT_FALSE(package_cache_.IsCached(key21, hash_file1_));
353 EXPECT_FALSE(package_cache_.IsCached(key22, hash_file2_));
354
355 EXPECT_EQ(0, package_cache_.Size());
356 }
357
358 TEST_F(PackageCacheTest, PurgeAppLowerVersionsTest) {
359 EXPECT_EQ(E_INVALIDARG, package_cache_.PurgeAppLowerVersions(_T("app1"),
360 _T("1")));
361
362 Key key_10_1(_T("app1"), _T("1.0.0.0"), _T("package1"));
363 Key key_10_2(_T("app1"), _T("1.0.0.0"), _T("package2"));
364 Key key_11_1(_T("app1"), _T("1.1.0.0"), _T("package1"));
365 Key key_21_2(_T("app1"), _T("2.1.0.0"), _T("package2"));
366
367 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key_10_1,
368 source_file1_,
369 hash_file1_));
370 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key_10_2,
371 source_file2_,
372 hash_file2_));
373 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key_11_1,
374 source_file1_,
375 hash_file1_));
376 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key_21_2,
377 source_file2_,
378 hash_file2_));
379
380 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAppLowerVersions(_T("app1"),
381 _T("1.0.0.0")));
382 EXPECT_TRUE(package_cache_.IsCached(key_10_1, hash_file1_));
383 EXPECT_TRUE(package_cache_.IsCached(key_10_2, hash_file2_));
384 EXPECT_TRUE(package_cache_.IsCached(key_11_1, hash_file1_));
385 EXPECT_TRUE(package_cache_.IsCached(key_21_2, hash_file2_));
386
387 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAppLowerVersions(_T("app1"),
388 _T("1.1.0.0")));
389 EXPECT_FALSE(package_cache_.IsCached(key_10_1, hash_file1_));
390 EXPECT_FALSE(package_cache_.IsCached(key_10_2, hash_file2_));
391 EXPECT_TRUE(package_cache_.IsCached(key_11_1, hash_file1_));
392 EXPECT_TRUE(package_cache_.IsCached(key_21_2, hash_file2_));
393
394 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAppLowerVersions(_T("app1"),
395 _T("2.1.0.0")));
396 EXPECT_FALSE(package_cache_.IsCached(key_11_1, hash_file1_));
397 EXPECT_TRUE(package_cache_.IsCached(key_21_2, hash_file2_));
398
399 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAppLowerVersions(_T("app1"),
400 _T("2.2.0.0")));
401 EXPECT_FALSE(package_cache_.IsCached(key_21_2, hash_file2_));
402
403 EXPECT_EQ(0, package_cache_.Size());
404 }
405
406 TEST_F(PackageCacheTest, PurgeAll) {
407 // Cache two files for two apps.
408 Key key11(_T("app1"), _T("ver1"), _T("package1"));
409 Key key12(_T("app1"), _T("ver1"), _T("package2"));
410 Key key21(_T("app2"), _T("ver2"), _T("package1"));
411 Key key22(_T("app2"), _T("ver2"), _T("package2"));
412
413 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key11,
414 source_file1_,
415 hash_file1_));
416 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key12,
417 source_file2_,
418 hash_file2_));
419 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key21,
420 source_file1_,
421 hash_file1_));
422 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key22,
423 source_file2_,
424 hash_file2_));
425
426 EXPECT_TRUE(package_cache_.IsCached(key11, hash_file1_));
427 EXPECT_TRUE(package_cache_.IsCached(key12, hash_file2_));
428 EXPECT_TRUE(package_cache_.IsCached(key21, hash_file1_));
429 EXPECT_TRUE(package_cache_.IsCached(key22, hash_file2_));
430
431 EXPECT_EQ(2 * (size_file1_ + size_file2_), package_cache_.Size());
432
433 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAll());
434
435 EXPECT_FALSE(package_cache_.IsCached(key11, hash_file1_));
436 EXPECT_FALSE(package_cache_.IsCached(key12, hash_file2_));
437 EXPECT_FALSE(package_cache_.IsCached(key21, hash_file1_));
438 EXPECT_FALSE(package_cache_.IsCached(key22, hash_file2_));
439
440 EXPECT_EQ(0, package_cache_.Size());
441 }
442
443 TEST_F(PackageCacheTest, PurgeOldPackagesIfOverSizeLimit) {
444 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAll());
445
446 const int kCacheSizeLimitMB = 2;
447 SetCacheSizeLimitMB(kCacheSizeLimitMB);
448
449 const uint64 kSizeLimitBytes = 1024LL * 1024 * kCacheSizeLimitMB;
450
451 Key key0(_T("app0"), _T("version0"), _T("package0"));
452
453 // Keep adding packages until we exceed cache limit.
454 uint64 current_size = 0;
455 int i = 0;
456 while (current_size <= kSizeLimitBytes) {
457 CString app;
458 CString version;
459 CString package;
460 app.Format(_T("app%d"), i);
461 version.Format(_T("version%d"), i);
462 package.Format(_T("package%d"), i);
463 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(Key(app, version, package),
464 source_file1_,
465 hash_file1_));
466 current_size += size_file1_;
467 EXPECT_EQ(current_size, package_cache_.Size());
468 ++i;
469 }
470
471 // Verify that cache size limit is exceeded.
472 EXPECT_GT(package_cache_.Size(), kSizeLimitBytes);
473 EXPECT_TRUE(package_cache_.IsCached(key0, hash_file1_));
474
475 package_cache_.PurgeOldPackagesIfNecessary();
476
477 // Verify that the oldes package is purged and the cache size is below limit.
478 EXPECT_FALSE(package_cache_.IsCached(key0, hash_file1_));
479 EXPECT_LE(package_cache_.Size(), kSizeLimitBytes);
480 }
481
482 TEST_F(PackageCacheTest, PurgeExpiredCacheFiles) {
483 EXPECT_HRESULT_SUCCEEDED(package_cache_.PurgeAll());
484
485 const int kCacheLifeLimitDays = 100;
486 SetCacheTimeLimitDays(kCacheLifeLimitDays);
487
488 Key key1(_T("app1"), _T("version1"), _T("package1"));
489 Key key2(_T("app2"), _T("version2"), _T("package2"));
490 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key1,
491 source_file1_,
492 hash_file1_));
493 EXPECT_HRESULT_SUCCEEDED(package_cache_.Put(key2,
494 source_file2_,
495 hash_file2_));
496 EXPECT_TRUE(package_cache_.IsCached(key1, hash_file1_));
497 EXPECT_TRUE(package_cache_.IsCached(key2, hash_file2_));
498
499 // Expires one package and verifies it is purged.
500 EXPECT_HRESULT_SUCCEEDED(ExpireCache(key1));
501 package_cache_.PurgeOldPackagesIfNecessary();
502 EXPECT_FALSE(package_cache_.IsCached(key1, hash_file1_));
503 EXPECT_TRUE(package_cache_.IsCached(key2, hash_file2_));
504
505 // Expires another package and verifies it is purged.
506 EXPECT_HRESULT_SUCCEEDED(ExpireCache(key2));
507 package_cache_.PurgeOldPackagesIfNecessary();
508 EXPECT_FALSE(package_cache_.IsCached(key1, hash_file1_));
509 EXPECT_FALSE(package_cache_.IsCached(key2, hash_file2_));
510 }
511
512 TEST_F(PackageCacheTest, AuthenticateFile) {
513 EXPECT_HRESULT_SUCCEEDED(PackageCache::AuthenticateFile(source_file1_,
514 hash_file1_));
515 EXPECT_EQ(SIGS_E_INVALID_SIGNATURE,
516 PackageCache::AuthenticateFile(source_file1_, hash_file2_));
517 }
518
519 } // namespace omaha
520
OLDNEW
« no previous file with comments | « goopdate/package_cache_internal.h ('k') | goopdate/process_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698