Commit a2691e83 authored by grt@chromium.org's avatar grt@chromium.org

Unit test for NULL values in preference validation delegate.

BUG=384729
R=gab@chromium.org, mattm@chromium.org

Review URL: https://codereview.chromium.org/332053005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277852 0039d316-1c4b-4281-b951-d872f2087c98
parent 7298e58a
...@@ -72,7 +72,7 @@ void PreferenceValidationDelegate::OnAtomicPreferenceValidation( ...@@ -72,7 +72,7 @@ void PreferenceValidationDelegate::OnAtomicPreferenceValidation(
void PreferenceValidationDelegate::OnSplitPreferenceValidation( void PreferenceValidationDelegate::OnSplitPreferenceValidation(
const std::string& pref_path, const std::string& pref_path,
const base::DictionaryValue* dict_value, const base::DictionaryValue* /* dict_value */,
const std::vector<std::string>& invalid_keys, const std::vector<std::string>& invalid_keys,
PrefHashStoreTransaction::ValueState value_state, PrefHashStoreTransaction::ValueState value_state,
TrackedPreferenceHelper::ResetAction /* reset_action */) { TrackedPreferenceHelper::ResetAction /* reset_action */) {
......
...@@ -83,6 +83,21 @@ class PreferenceValidationDelegateTest : public testing::Test { ...@@ -83,6 +83,21 @@ class PreferenceValidationDelegateTest : public testing::Test {
scoped_ptr<TrackedPreferenceValidationDelegate> instance_; scoped_ptr<TrackedPreferenceValidationDelegate> instance_;
}; };
// Tests that a NULL value results in an incident with no value.
TEST_F(PreferenceValidationDelegateTest, NullValue) {
instance_->OnAtomicPreferenceValidation(kPrefPath_,
NULL,
PrefHashStoreTransaction::CLEARED,
TrackedPreferenceHelper::DONT_RESET);
safe_browsing::ClientIncidentReport_IncidentData* incident =
incidents_.back();
EXPECT_FALSE(incident->tracked_preference().has_atomic_value());
EXPECT_EQ(
safe_browsing::
ClientIncidentReport_IncidentData_TrackedPreferenceIncident::CLEARED,
incident->tracked_preference().value_state());
}
// Tests that all supported value types can be stringified into an incident. The // Tests that all supported value types can be stringified into an incident. The
// parameters for the test are the type of value to test and the expected value // parameters for the test are the type of value to test and the expected value
// string. // string.
...@@ -137,6 +152,7 @@ TEST_P(PreferenceValidationDelegateValues, Value) { ...@@ -137,6 +152,7 @@ TEST_P(PreferenceValidationDelegateValues, Value) {
MakeValue(value_type_).get(), MakeValue(value_type_).get(),
PrefHashStoreTransaction::CLEARED, PrefHashStoreTransaction::CLEARED,
TrackedPreferenceHelper::DONT_RESET); TrackedPreferenceHelper::DONT_RESET);
ASSERT_EQ(1U, incidents_.size());
safe_browsing::ClientIncidentReport_IncidentData* incident = safe_browsing::ClientIncidentReport_IncidentData* incident =
incidents_.back(); incidents_.back();
EXPECT_EQ(std::string(expected_value_), EXPECT_EQ(std::string(expected_value_),
...@@ -214,7 +230,7 @@ class PreferenceValidationDelegateWithIncident ...@@ -214,7 +230,7 @@ class PreferenceValidationDelegateWithIncident
TEST_P(PreferenceValidationDelegateWithIncident, Atomic) { TEST_P(PreferenceValidationDelegateWithIncident, Atomic) {
instance_->OnAtomicPreferenceValidation( instance_->OnAtomicPreferenceValidation(
kPrefPath_, null_value_.get(), value_state_, reset_action_); kPrefPath_, null_value_.get(), value_state_, reset_action_);
EXPECT_EQ(1U, incidents_.size()); ASSERT_EQ(1U, incidents_.size());
safe_browsing::ClientIncidentReport_IncidentData* incident = safe_browsing::ClientIncidentReport_IncidentData* incident =
incidents_.back(); incidents_.back();
EXPECT_TRUE(incident->has_tracked_preference()); EXPECT_TRUE(incident->has_tracked_preference());
...@@ -232,7 +248,7 @@ TEST_P(PreferenceValidationDelegateWithIncident, Atomic) { ...@@ -232,7 +248,7 @@ TEST_P(PreferenceValidationDelegateWithIncident, Atomic) {
TEST_P(PreferenceValidationDelegateWithIncident, Split) { TEST_P(PreferenceValidationDelegateWithIncident, Split) {
instance_->OnSplitPreferenceValidation( instance_->OnSplitPreferenceValidation(
kPrefPath_, &dict_value_, invalid_keys_, value_state_, reset_action_); kPrefPath_, &dict_value_, invalid_keys_, value_state_, reset_action_);
EXPECT_EQ(1U, incidents_.size()); ASSERT_EQ(1U, incidents_.size());
safe_browsing::ClientIncidentReport_IncidentData* incident = safe_browsing::ClientIncidentReport_IncidentData* incident =
incidents_.back(); incidents_.back();
EXPECT_TRUE(incident->has_tracked_preference()); EXPECT_TRUE(incident->has_tracked_preference());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment