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

Unified Diff: chrome/browser/profiles/profile_attributes_storage_unittest.cc

Issue 1415223002: Add counts of User data to ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix. Removed a non-trivial style fix (will upload in another CL). Created 5 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 | « chrome/browser/profiles/profile_attributes_entry.cc ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_attributes_storage_unittest.cc
diff --git a/chrome/browser/profiles/profile_attributes_storage_unittest.cc b/chrome/browser/profiles/profile_attributes_storage_unittest.cc
index b3668121d249b0c1db37cf2f84bbbca2681054f2..9f8a153f487b7c85fe082ec6c08da408b8bf6911 100644
--- a/chrome/browser/profiles/profile_attributes_storage_unittest.cc
+++ b/chrome/browser/profiles/profile_attributes_storage_unittest.cc
@@ -34,11 +34,19 @@ namespace {
std::string("second_" #member "_value"));
#define TEST_BOOL_ACCESSORS(entry_type, entry, member) \
-TestAccessors(&entry, \
- &entry_type::member, \
- &entry_type::Set ## member, \
- false, \
- true);
+ TestAccessors(&entry, \
+ &entry_type::member, \
+ &entry_type::Set ## member, \
+ false, \
+ true);
+
+#define TEST_STAT_ACCESSORS(entry_type, entry, member) \
+ TestStatAccessors(&entry, \
+ &entry_type::Has ## member, \
+ &entry_type::Get ## member, \
+ &entry_type::Set ## member, \
+ 10, \
+ 20);
template<typename TValue, typename TGetter, typename TSetter>
void TestAccessors(ProfileAttributesEntry** entry,
@@ -51,6 +59,22 @@ void TestAccessors(ProfileAttributesEntry** entry,
(*entry->*setter_func)(second_value);
EXPECT_EQ(second_value, (*entry->*getter_func)());
}
+
+template<typename TValue, typename TExist, typename TGetter, typename TSetter>
+void TestStatAccessors(ProfileAttributesEntry** entry,
+ TExist exist_func,
+ TGetter getter_func,
+ TSetter setter_func,
+ TValue first_value,
+ TValue second_value) {
+ EXPECT_FALSE((*entry->*exist_func)());
+ (*entry->*setter_func)(first_value);
+ EXPECT_TRUE((*entry->*exist_func)());
+ EXPECT_EQ(first_value, (*entry->*getter_func)());
+ (*entry->*setter_func)(second_value);
+ EXPECT_TRUE((*entry->*exist_func)());
+ EXPECT_EQ(second_value, (*entry->*getter_func)());
+}
} // namespace
class ProfileAttributesStorageTest : public testing::Test {
@@ -183,7 +207,7 @@ TEST_F(ProfileAttributesStorageTest, MultipleProfiles) {
std::vector<ProfileAttributesEntry*> entries =
storage()->GetAllProfilesAttributes();
- for (auto& entry: entries) {
+ for (auto& entry : entries) {
EXPECT_NE(GetProfilePath("testing_profile_path0"), entry->GetPath());
}
}
@@ -227,6 +251,11 @@ TEST_F(ProfileAttributesStorageTest, EntryAccessors) {
TEST_BOOL_ACCESSORS(ProfileAttributesEntry, entry, IsUsingDefaultName);
TEST_BOOL_ACCESSORS(ProfileAttributesEntry, entry, IsUsingDefaultAvatar);
TEST_BOOL_ACCESSORS(ProfileAttributesEntry, entry, IsAuthError);
+
+ TEST_STAT_ACCESSORS(ProfileAttributesEntry, entry, StatsBrowsingHistory);
+ TEST_STAT_ACCESSORS(ProfileAttributesEntry, entry, StatsBookmarks);
+ TEST_STAT_ACCESSORS(ProfileAttributesEntry, entry, StatsPasswords);
+ TEST_STAT_ACCESSORS(ProfileAttributesEntry, entry, StatsSettings);
}
TEST_F(ProfileAttributesStorageTest, AuthInfo) {
@@ -310,7 +339,7 @@ TEST_F(ProfileAttributesStorageTest, RemoveOtherProfile) {
GetProfilePath("testing_profile_path1"), &second_entry));
EXPECT_EQ(
- base::ASCIIToUTF16("testing_profile_name0"),first_entry->GetName());
+ base::ASCIIToUTF16("testing_profile_name0"), first_entry->GetName());
storage()->RemoveProfile(GetProfilePath("testing_profile_path1"));
ASSERT_FALSE(storage()->GetProfileAttributesWithPath(
« no previous file with comments | « chrome/browser/profiles/profile_attributes_entry.cc ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698