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

Side by Side Diff: components/update_client/persisted_data_unittest.cc

Issue 1861383004: Add module for counting date-last-roll-call and persisting those counts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another test fix. Created 4 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6 #include <vector>
7
8 #include "components/prefs/testing_pref_service.h"
9 #include "components/update_client/persisted_data.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace update_client {
13
14 TEST(PersistedDataTest, Simple) {
15 std::unique_ptr<TestingPrefServiceSimple> pref(
16 new TestingPrefServiceSimple());
17 PersistedData::RegisterPrefs(pref->registry());
18 std::unique_ptr<PersistedData> metadata(new PersistedData(pref.get()));
19 EXPECT_EQ(-2, metadata->GetDateLastRollCall("someappid"));
20 std::vector<std::string> items;
21 items.push_back("someappid");
22 metadata->SetDateLastRollCall(items, 3383);
23 EXPECT_EQ(3383, metadata->GetDateLastRollCall("someappid"));
24 EXPECT_EQ(-2, metadata->GetDateLastRollCall("someotherappid"));
25 metadata->SetDateLastRollCall(items, 3386);
26 EXPECT_EQ(3386, metadata->GetDateLastRollCall("someappid"));
27 EXPECT_EQ(-2, metadata->GetDateLastRollCall("someotherappid"));
28 }
29
30 TEST(PersistedDataTest, SharedPref) {
31 std::unique_ptr<TestingPrefServiceSimple> pref(
32 new TestingPrefServiceSimple());
33 PersistedData::RegisterPrefs(pref->registry());
34 std::unique_ptr<PersistedData> metadata(new PersistedData(pref.get()));
35 EXPECT_EQ(-2, metadata->GetDateLastRollCall("someappid"));
36 std::vector<std::string> items;
37 items.push_back("someappid");
38 metadata->SetDateLastRollCall(items, 3383);
39
40 // Now, create a new PersistedData reading from the same path, verify
41 // that it loads the value.
42 metadata.reset(new PersistedData(pref.get()));
43 EXPECT_EQ(3383, metadata->GetDateLastRollCall("someappid"));
44 EXPECT_EQ(-2, metadata->GetDateLastRollCall("someotherappid"));
45 }
46
47 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/persisted_data.cc ('k') | components/update_client/test_configurator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698