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

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

Issue 2252093002: Add support for Omaha cohorts to the component updater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test Created 4 years, 3 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
« no previous file with comments | « components/update_client/persisted_data.cc ('k') | components/update_client/update_checker.cc » ('j') | 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 <memory>
5 #include <string> 6 #include <string>
6 #include <vector> 7 #include <vector>
7 8
8 #include "components/prefs/testing_pref_service.h" 9 #include "components/prefs/testing_pref_service.h"
9 #include "components/update_client/persisted_data.h" 10 #include "components/update_client/persisted_data.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace update_client { 13 namespace update_client {
13 14
14 TEST(PersistedDataTest, Simple) { 15 TEST(PersistedDataTest, Simple) {
(...skipping 28 matching lines...) Expand all
43 items.push_back("someappid"); 44 items.push_back("someappid");
44 metadata->SetDateLastRollCall(items, 3383); 45 metadata->SetDateLastRollCall(items, 3383);
45 46
46 // Now, create a new PersistedData reading from the same path, verify 47 // Now, create a new PersistedData reading from the same path, verify
47 // that it loads the value. 48 // that it loads the value.
48 metadata.reset(new PersistedData(pref.get())); 49 metadata.reset(new PersistedData(pref.get()));
49 EXPECT_EQ(3383, metadata->GetDateLastRollCall("someappid")); 50 EXPECT_EQ(3383, metadata->GetDateLastRollCall("someappid"));
50 EXPECT_EQ(-2, metadata->GetDateLastRollCall("someotherappid")); 51 EXPECT_EQ(-2, metadata->GetDateLastRollCall("someotherappid"));
51 } 52 }
52 53
54 TEST(PersistedDataTest, SimpleCohort) {
55 std::unique_ptr<TestingPrefServiceSimple> pref(
56 new TestingPrefServiceSimple());
57 PersistedData::RegisterPrefs(pref->registry());
58 std::unique_ptr<PersistedData> metadata(new PersistedData(pref.get()));
59 EXPECT_EQ("", metadata->GetCohort("someappid"));
60 EXPECT_EQ("", metadata->GetCohort("someotherappid"));
61 EXPECT_EQ("", metadata->GetCohortHint("someappid"));
62 EXPECT_EQ("", metadata->GetCohortHint("someotherappid"));
63 EXPECT_EQ("", metadata->GetCohortName("someappid"));
64 EXPECT_EQ("", metadata->GetCohortName("someotherappid"));
65 metadata->SetCohort("someappid", "c1");
66 metadata->SetCohort("someotherappid", "c2");
67 metadata->SetCohortHint("someappid", "ch1");
68 metadata->SetCohortHint("someotherappid", "ch2");
69 metadata->SetCohortName("someappid", "cn1");
70 metadata->SetCohortName("someotherappid", "cn2");
71 EXPECT_EQ("c1", metadata->GetCohort("someappid"));
72 EXPECT_EQ("c2", metadata->GetCohort("someotherappid"));
73 EXPECT_EQ("ch1", metadata->GetCohortHint("someappid"));
74 EXPECT_EQ("ch2", metadata->GetCohortHint("someotherappid"));
75 EXPECT_EQ("cn1", metadata->GetCohortName("someappid"));
76 EXPECT_EQ("cn2", metadata->GetCohortName("someotherappid"));
77 metadata->SetCohort("someappid", "oc1");
78 metadata->SetCohort("someotherappid", "oc2");
79 metadata->SetCohortHint("someappid", "och1");
80 metadata->SetCohortHint("someotherappid", "och2");
81 metadata->SetCohortName("someappid", "ocn1");
82 metadata->SetCohortName("someotherappid", "ocn2");
83 EXPECT_EQ("oc1", metadata->GetCohort("someappid"));
84 EXPECT_EQ("oc2", metadata->GetCohort("someotherappid"));
85 EXPECT_EQ("och1", metadata->GetCohortHint("someappid"));
86 EXPECT_EQ("och2", metadata->GetCohortHint("someotherappid"));
87 EXPECT_EQ("ocn1", metadata->GetCohortName("someappid"));
88 EXPECT_EQ("ocn2", metadata->GetCohortName("someotherappid"));
89 }
90
53 } // namespace update_client 91 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/persisted_data.cc ('k') | components/update_client/update_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698