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

Unified Diff: chromeos/printing/ppd_cache_unittest.cc

Issue 2487343006: Add in-memory caching to PpdCache available printers. (Closed)
Patch Set: Address thestig@ comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/printing/ppd_cache.cc ('k') | chromeos/printing/ppd_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/printing/ppd_cache_unittest.cc
diff --git a/chromeos/printing/ppd_cache_unittest.cc b/chromeos/printing/ppd_cache_unittest.cc
index 83dd2e12e588ed666f711282cd30a8997dcd6107..9df8d4f395f954dac557504a037ce3a013146f76 100644
--- a/chromeos/printing/ppd_cache_unittest.cc
+++ b/chromeos/printing/ppd_cache_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <utility>
+
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
@@ -152,22 +154,23 @@ TEST_F(PpdCacheTest, StoreAndRetrieveAvailablePrinters) {
auto cache = CreateTestCache();
// Nothing stored, so should miss in the cache.
- base::Optional<PpdProvider::AvailablePrintersMap> result =
+ const PpdProvider::AvailablePrintersMap* result =
cache->FindAvailablePrinters();
- EXPECT_FALSE(result);
+ EXPECT_EQ(nullptr, result);
// Create something to store.
- PpdProvider::AvailablePrintersMap a;
- a["foo"] = {"bar", "baz", "sna"};
- a["bar"] = {"c", "d", "e"};
- a["baz"] = {"f", "g", "h"};
+ auto a = base::MakeUnique<PpdProvider::AvailablePrintersMap>();
+ (*a)["foo"] = {"bar", "baz", "sna"};
+ (*a)["bar"] = {"c", "d", "e"};
+ (*a)["baz"] = {"f", "g", "h"};
+ PpdProvider::AvailablePrintersMap original = *a;
// Store it, get it back.
- cache->StoreAvailablePrinters(a);
+ cache->StoreAvailablePrinters(std::move(a));
result = cache->FindAvailablePrinters();
- ASSERT_TRUE(result);
+ ASSERT_NE(nullptr, result);
- EXPECT_EQ(a, result.value());
+ EXPECT_EQ(original, *result);
}
// When an entry is too old, we shouldn't return it.
@@ -178,10 +181,11 @@ TEST_F(PpdCacheTest, ExpireStaleAvailablePrinters) {
auto cache = CreateTestCache(options);
// Store an empty map. (Contents don't really matter for this test).
- cache->StoreAvailablePrinters(PpdProvider::AvailablePrintersMap());
+ cache->StoreAvailablePrinters(
+ base::MakeUnique<PpdProvider::AvailablePrintersMap>());
// Should *miss* in the cache because the entry is already expired.
- EXPECT_FALSE(cache->FindAvailablePrinters());
+ EXPECT_EQ(nullptr, cache->FindAvailablePrinters());
}
} // namespace
« no previous file with comments | « chromeos/printing/ppd_cache.cc ('k') | chromeos/printing/ppd_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698