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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_cache_metadata_unittest.cc

Issue 10765020: gdata: Simplify semantics of sub_dir_type in CacheEntry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 "chrome/browser/chromeos/gdata/gdata_cache_metadata.h" 5 #include "chrome/browser/chromeos/gdata/gdata_cache_metadata.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "chrome/browser/chromeos/gdata/gdata_util.h" 9 #include "chrome/browser/chromeos/gdata/gdata_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 cache_entry = metadata_->GetCacheEntry("id_symlink_tmp", ""); 329 cache_entry = metadata_->GetCacheEntry("id_symlink_tmp", "");
330 EXPECT_FALSE(cache_entry.get()); 330 EXPECT_FALSE(cache_entry.get());
331 EXPECT_FALSE(PathExists(pinned_directory_.AppendASCII("id_symlink_tmp"))); 331 EXPECT_FALSE(PathExists(pinned_directory_.AppendASCII("id_symlink_tmp")));
332 332
333 // Check contents in "pinned" directory. 333 // Check contents in "pinned" directory.
334 // 334 //
335 // "id_corge" is pinned but not present. 335 // "id_corge" is pinned but not present.
336 cache_entry = metadata_->GetCacheEntry("id_corge", ""); 336 cache_entry = metadata_->GetCacheEntry("id_corge", "");
337 ASSERT_TRUE(cache_entry.get()); 337 ASSERT_TRUE(cache_entry.get());
338 EXPECT_EQ("", cache_entry->md5); 338 EXPECT_EQ("", cache_entry->md5);
339 EXPECT_EQ(GDataCache::CACHE_TYPE_PINNED, cache_entry->sub_dir_type); 339 EXPECT_EQ(GDataCache::CACHE_TYPE_TMP, cache_entry->sub_dir_type);
340 EXPECT_EQ(GDataCache::CACHE_STATE_PINNED, cache_entry->cache_state); 340 EXPECT_EQ(GDataCache::CACHE_STATE_PINNED, cache_entry->cache_state);
341 EXPECT_TRUE(IsLink(pinned_directory_.AppendASCII("id_corge"))); 341 EXPECT_TRUE(IsLink(pinned_directory_.AppendASCII("id_corge")));
342 342
343 // "id_dangling" should be removed during cache initialization. 343 // "id_dangling" should be removed during cache initialization.
344 cache_entry = metadata_->GetCacheEntry("id_dangling", ""); 344 cache_entry = metadata_->GetCacheEntry("id_dangling", "");
345 EXPECT_FALSE(cache_entry.get()); 345 EXPECT_FALSE(cache_entry.get());
346 EXPECT_FALSE(IsLink(pinned_directory_.AppendASCII("id_dangling"))); 346 EXPECT_FALSE(IsLink(pinned_directory_.AppendASCII("id_dangling")));
347 347
348 // "id_outside" should be removed during cache initialization. 348 // "id_outside" should be removed during cache initialization.
349 cache_entry = metadata_->GetCacheEntry("id_outside", ""); 349 cache_entry = metadata_->GetCacheEntry("id_outside", "");
(...skipping 12 matching lines...) Expand all
362 362
363 GDataCacheMetadataMap::CacheMap cache_map; 363 GDataCacheMetadataMap::CacheMap cache_map;
364 InsertIntoMap(&cache_map, 364 InsertIntoMap(&cache_map,
365 "<resource_id_1>", 365 "<resource_id_1>",
366 "<md5>", 366 "<md5>",
367 GDataCache::CACHE_TYPE_TMP, 367 GDataCache::CACHE_TYPE_TMP,
368 GDataCache::CACHE_STATE_PRESENT); 368 GDataCache::CACHE_STATE_PRESENT);
369 InsertIntoMap(&cache_map, 369 InsertIntoMap(&cache_map,
370 "<resource_id_2>", 370 "<resource_id_2>",
371 "<md5>", 371 "<md5>",
372 GDataCache::CACHE_TYPE_PINNED, 372 GDataCache::CACHE_TYPE_PERSISTENT,
373 GDataCache::CACHE_STATE_PRESENT); 373 GDataCache::CACHE_STATE_PRESENT);
374 InsertIntoMap(&cache_map, 374 InsertIntoMap(&cache_map,
375 "<resource_id_3>", 375 "<resource_id_3>",
376 "<md5>", 376 "<md5>",
377 GDataCache::CACHE_TYPE_OUTGOING, 377 GDataCache::CACHE_TYPE_PERSISTENT,
hshi1 2012/07/10 00:45:53 This seems to be the only line of change in your p
satorux1 2012/07/10 03:18:56 Yes, this is intentional. We don't store cache fil
378 GDataCache::CACHE_STATE_PRESENT); 378 GDataCache::CACHE_STATE_PRESENT);
379 InsertIntoMap(&cache_map, 379 InsertIntoMap(&cache_map,
380 "<resource_id_4>", 380 "<resource_id_4>",
381 "<md5>", 381 "<md5>",
382 GDataCache::CACHE_TYPE_TMP, 382 GDataCache::CACHE_TYPE_TMP,
383 GDataCache::CACHE_STATE_PRESENT); 383 GDataCache::CACHE_STATE_PRESENT);
384 384
385 metadata_->cache_map_ = cache_map; 385 metadata_->cache_map_ = cache_map;
386 metadata_->RemoveTemporaryFiles(); 386 metadata_->RemoveTemporaryFiles();
387 // resource 1 and 4 should be gone, as these are CACHE_TYPE_TMP. 387 // resource 1 and 4 should be gone, as these are CACHE_TYPE_TMP.
388 EXPECT_FALSE(metadata_->GetCacheEntry("<resource_id_1>", "").get()); 388 EXPECT_FALSE(metadata_->GetCacheEntry("<resource_id_1>", "").get());
389 EXPECT_TRUE(metadata_->GetCacheEntry("<resource_id_2>", "").get()); 389 EXPECT_TRUE(metadata_->GetCacheEntry("<resource_id_2>", "").get());
390 EXPECT_TRUE(metadata_->GetCacheEntry("<resource_id_3>", "").get()); 390 EXPECT_TRUE(metadata_->GetCacheEntry("<resource_id_3>", "").get());
391 EXPECT_FALSE(metadata_->GetCacheEntry("<resource_id_4>", "").get()); 391 EXPECT_FALSE(metadata_->GetCacheEntry("<resource_id_4>", "").get());
392 } 392 }
393 393
394 } // namespace gdata 394 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_cache_metadata.cc ('k') | chrome/browser/chromeos/gdata/gdata_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698