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

Side by Side Diff: chromeos/printing/ppd_cache_unittest.cc

Issue 2516513002: Lazily create PPDCache directory on first store. (Closed)
Patch Set: Created 4 years, 1 month 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 | « chromeos/printing/ppd_cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/hash.h" 10 #include "base/hash.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // This fixture just points the cache at a temporary directory for the life of 46 // This fixture just points the cache at a temporary directory for the life of
47 // the test. 47 // the test.
48 class PpdCacheTest : public ::testing::Test { 48 class PpdCacheTest : public ::testing::Test {
49 public: 49 public:
50 void SetUp() override { 50 void SetUp() override {
51 ASSERT_TRUE(ppd_cache_temp_dir_.CreateUniqueTempDir()); 51 ASSERT_TRUE(ppd_cache_temp_dir_.CreateUniqueTempDir());
52 } 52 }
53 53
54 // Make and return a cache for the test that uses a temporary directory 54 // Make and return a cache for the test that uses a temporary directory
55 // which is cleaned up at the end of the test. 55 // which is cleaned up at the end of the test. Note that we pass
56 // a (nonexistant) subdirectory of temp_dir_ to the cache to exercise
57 // the lazy-creation-of-the-cache-directory code.
56 std::unique_ptr<PpdCache> CreateTestCache( 58 std::unique_ptr<PpdCache> CreateTestCache(
57 const PpdCache::Options& options = PpdCache::Options()) { 59 const PpdCache::Options& options = PpdCache::Options()) {
58 return PpdCache::Create(ppd_cache_temp_dir_.GetPath(), options); 60 return PpdCache::Create(ppd_cache_temp_dir_.GetPath().Append("Cache"),
61 options);
59 } 62 }
60 63
61 protected: 64 protected:
62 // Overrider for DIR_CHROMEOS_PPD_CACHE that points it at a temporary 65 // Overrider for DIR_CHROMEOS_PPD_CACHE that points it at a temporary
63 // directory for the life of the test. 66 // directory for the life of the test.
64 base::ScopedTempDir ppd_cache_temp_dir_; 67 base::ScopedTempDir ppd_cache_temp_dir_;
65 }; 68 };
66 69
67 // Check that path has a value, and the contents of the referenced file are 70 // Check that path has a value, and the contents of the referenced file are
68 // |expected_contents|. 71 // |expected_contents|.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 cache->StoreAvailablePrinters( 187 cache->StoreAvailablePrinters(
185 base::MakeUnique<PpdProvider::AvailablePrintersMap>()); 188 base::MakeUnique<PpdProvider::AvailablePrintersMap>());
186 189
187 // Should *miss* in the cache because the entry is already expired. 190 // Should *miss* in the cache because the entry is already expired.
188 EXPECT_EQ(nullptr, cache->FindAvailablePrinters()); 191 EXPECT_EQ(nullptr, cache->FindAvailablePrinters());
189 } 192 }
190 193
191 } // namespace 194 } // namespace
192 } // namespace printing 195 } // namespace printing
193 } // namespace chromeos 196 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/printing/ppd_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698