diff options
author | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-03 08:43:37 +0000 |
---|---|---|
committer | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-03 08:43:37 +0000 |
commit | 5d30f92bf4e9f055d44ea0db2327b036ae41eef6 (patch) | |
tree | e4237d83ef224e420140e6411ac84f60216555d1 /base/debug | |
parent | 4ccaee6820cb8ac79581141a4f2463a2abb38442 (diff) | |
download | chromium_src-5d30f92bf4e9f055d44ea0db2327b036ae41eef6.zip chromium_src-5d30f92bf4e9f055d44ea0db2327b036ae41eef6.tar.gz chromium_src-5d30f92bf4e9f055d44ea0db2327b036ae41eef6.tar.bz2 |
Correct const accessors in base/values.(h|cc), Part II (ListValue)
For problem description and other info please see the BUG page.
This is for ListValue.
BUG=138946
TEST=N/A (no fix & no new feature)
TBR=jar,zelidrag,scottbyer,mpcomplete,darin,achuith,sky,estade,atwilson,grt,thakis,jamesr,hans,sadrul,pastarmovj
Review URL: https://chromiumcodereview.appspot.com/10837044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug')
-rw-r--r-- | base/debug/trace_event_unittest.cc | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc index f839d27..5d32f2f 100644 --- a/base/debug/trace_event_unittest.cc +++ b/base/debug/trace_event_unittest.cc @@ -220,10 +220,10 @@ bool TraceEventTestFixture::FindNonMatchingValue(const char* key, return FindMatchingTraceEntry(key_values); } -bool IsStringInDict(const char* string_to_match, DictionaryValue* dict) { +bool IsStringInDict(const char* string_to_match, const DictionaryValue* dict) { for (DictionaryValue::key_iterator ikey = dict->begin_keys(); ikey != dict->end_keys(); ++ikey) { - Value* child = NULL; + const Value* child = NULL; if (!dict->GetWithoutPathExpansion(*ikey, &child)) continue; @@ -237,7 +237,7 @@ bool IsStringInDict(const char* string_to_match, DictionaryValue* dict) { } // Recurse to test arguments - DictionaryValue* args_dict = NULL; + const DictionaryValue* args_dict = NULL; dict->GetDictionary("args", &args_dict); if (args_dict) return IsStringInDict(string_to_match, args_dict); @@ -245,13 +245,14 @@ bool IsStringInDict(const char* string_to_match, DictionaryValue* dict) { return false; } -DictionaryValue* FindTraceEntry(const ListValue& trace_parsed, - const char* string_to_match, - DictionaryValue* match_after_this_item = NULL) { +const DictionaryValue* FindTraceEntry( + const ListValue& trace_parsed, + const char* string_to_match, + const DictionaryValue* match_after_this_item = NULL) { // Scan all items size_t trace_parsed_count = trace_parsed.GetSize(); for (size_t i = 0; i < trace_parsed_count; i++) { - Value* value = NULL; + const Value* value = NULL; trace_parsed.Get(i, &value); if (match_after_this_item) { if (value == match_after_this_item) @@ -260,7 +261,7 @@ DictionaryValue* FindTraceEntry(const ListValue& trace_parsed, } if (!value || value->GetType() != Value::TYPE_DICTIONARY) continue; - DictionaryValue* dict = static_cast<DictionaryValue*>(value); + const DictionaryValue* dict = static_cast<const DictionaryValue*>(value); if (IsStringInDict(string_to_match, dict)) return dict; @@ -268,17 +269,17 @@ DictionaryValue* FindTraceEntry(const ListValue& trace_parsed, return NULL; } -std::vector<DictionaryValue*> FindTraceEntries( +std::vector<const DictionaryValue*> FindTraceEntries( const ListValue& trace_parsed, const char* string_to_match) { - std::vector<DictionaryValue*> hits; + std::vector<const DictionaryValue*> hits; size_t trace_parsed_count = trace_parsed.GetSize(); for (size_t i = 0; i < trace_parsed_count; i++) { - Value* value = NULL; + const Value* value = NULL; trace_parsed.Get(i, &value); if (!value || value->GetType() != Value::TYPE_DICTIONARY) continue; - DictionaryValue* dict = static_cast<DictionaryValue*>(value); + const DictionaryValue* dict = static_cast<const DictionaryValue*>(value); if (IsStringInDict(string_to_match, dict)) hits.push_back(dict); @@ -365,7 +366,7 @@ void TraceWithAllMacroVariants(WaitableEvent* task_complete_event) { } void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) { - DictionaryValue* item = NULL; + const DictionaryValue* item = NULL; #define EXPECT_FIND_(string) \ EXPECT_TRUE((item = FindTraceEntry(trace_parsed, string))); @@ -598,11 +599,11 @@ void ValidateInstantEventPresentOnEveryThread(const ListValue& trace_parsed, size_t trace_parsed_count = trace_parsed.GetSize(); for (size_t i = 0; i < trace_parsed_count; i++) { - Value* value = NULL; + const Value* value = NULL; trace_parsed.Get(i, &value); if (!value || value->GetType() != Value::TYPE_DICTIONARY) continue; - DictionaryValue* dict = static_cast<DictionaryValue*>(value); + const DictionaryValue* dict = static_cast<const DictionaryValue*>(value); std::string name; dict->GetString("name", &name); if (name != "multi thread event") @@ -1149,12 +1150,12 @@ TEST_F(TraceEventTestFixture, ThreadNames) { std::string tmp; int tmp_int; - DictionaryValue* item; + const DictionaryValue* item; // Make sure we get thread name metadata. // Note, the test suite may have created a ton of threads. // So, we'll have thread names for threads we didn't create. - std::vector<DictionaryValue*> items = + std::vector<const DictionaryValue*> items = FindTraceEntries(trace_parsed_, "thread_name"); for (int i = 0; i < static_cast<int>(items.size()); i++) { item = items[i]; @@ -1201,11 +1202,11 @@ TEST_F(TraceEventTestFixture, ThreadNameChanges) { TraceLog::GetInstance()->SetEnabled(false); - std::vector<DictionaryValue*> items = + std::vector<const DictionaryValue*> items = FindTraceEntries(trace_parsed_, "thread_name"); EXPECT_EQ(1u, items.size()); ASSERT_GT(items.size(), 0u); - DictionaryValue* item = items[0]; + const DictionaryValue* item = items[0]; ASSERT_TRUE(item); int tid; EXPECT_TRUE(item->GetInteger("tid", &tid)); @@ -1250,7 +1251,7 @@ TEST_F(TraceEventTestFixture, AtExit) { ASSERT_FALSE(TraceLog::GetInstance()); // Now that singleton is destroyed, check what trace events were recorded - DictionaryValue* item = NULL; + const DictionaryValue* item = NULL; ListValue& trace_parsed = trace_parsed_; EXPECT_FIND_("is recorded 1"); EXPECT_FIND_("is recorded 2"); @@ -1330,9 +1331,9 @@ TEST_F(TraceEventTestFixture, DeepCopy) { EXPECT_FALSE(FindTraceEntry(trace_parsed_, name2.c_str())); EXPECT_FALSE(FindTraceEntry(trace_parsed_, name3.c_str())); - DictionaryValue* entry1 = FindTraceEntry(trace_parsed_, kOriginalName1); - DictionaryValue* entry2 = FindTraceEntry(trace_parsed_, kOriginalName2); - DictionaryValue* entry3 = FindTraceEntry(trace_parsed_, kOriginalName3); + const DictionaryValue* entry1 = FindTraceEntry(trace_parsed_, kOriginalName1); + const DictionaryValue* entry2 = FindTraceEntry(trace_parsed_, kOriginalName2); + const DictionaryValue* entry3 = FindTraceEntry(trace_parsed_, kOriginalName3); ASSERT_TRUE(entry1); ASSERT_TRUE(entry2); ASSERT_TRUE(entry3); |