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

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: ASAN 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 class PersistedDataTest : public testing::Test {
Bernhard Bauer 2016/04/08 09:06:10 You don't need to add an empty test fixture. Just
waffles 2016/04/08 19:11:01 Done.
15 public:
16 PersistedDataTest();
17 ~PersistedDataTest() override;
18
19 private:
20 DISALLOW_COPY_AND_ASSIGN(PersistedDataTest);
21 };
22
23 PersistedDataTest::PersistedDataTest() {
24 }
25
26 PersistedDataTest::~PersistedDataTest() {
27 }
28
29 TEST_F(PersistedDataTest, Simple) {
30 scoped_ptr<TestingPrefServiceSimple> pref(new TestingPrefServiceSimple());
Bernhard Bauer 2016/04/08 09:06:10 Nit: scoped_ptr<> is deprecated now! 😃 Use std::un
waffles 2016/04/08 19:11:01 Done.
31 RegisterPersistedDataPreferences(pref->registry());
32 scoped_refptr<PersistedData> metadata(new PersistedData(pref.get()));
33 EXPECT_EQ(-2, metadata->DateLastRollCall("someappid"));
34 std::vector<std::string> items;
35 items.push_back("someappid");
36 metadata->SetDateLastRollCall(items, 3383);
37 EXPECT_EQ(3383, metadata->DateLastRollCall("someappid"));
38 EXPECT_EQ(-2, metadata->DateLastRollCall("someotherappid"));
39 metadata->SetDateLastRollCall(items, 3386);
40 EXPECT_EQ(3386, metadata->DateLastRollCall("someappid"));
41 EXPECT_EQ(-2, metadata->DateLastRollCall("someotherappid"));
42 }
43
44 TEST_F(PersistedDataTest, SharedPref) {
45 scoped_ptr<TestingPrefServiceSimple> pref(new TestingPrefServiceSimple());
46 RegisterPersistedDataPreferences(pref->registry());
47 scoped_refptr<PersistedData> metadata(new PersistedData(pref.get()));
48 EXPECT_EQ(-2, metadata->DateLastRollCall("someappid"));
49 std::vector<std::string> items;
50 items.push_back("someappid");
51 metadata->SetDateLastRollCall(items, 3383);
52
53 // Now, create a new PersistedData reading from the same path, verify
54 // that it loads the value.
55 metadata = new PersistedData(pref.get());
56 EXPECT_EQ(3383, metadata->DateLastRollCall("someappid"));
57 EXPECT_EQ(-2, metadata->DateLastRollCall("someotherappid"));
58 }
59
60 } // namespace update_client
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698