Index: cc/debug/rendering_stats_unittest.cc |
diff --git a/cc/debug/rendering_stats_unittest.cc b/cc/debug/rendering_stats_unittest.cc |
index a634093237139511ec723cd8c83c7027787f1d46..ea0276c4de4cc9b70c457a5d6f539e323ecab696 100644 |
--- a/cc/debug/rendering_stats_unittest.cc |
+++ b/cc/debug/rendering_stats_unittest.cc |
@@ -1,8 +1,6 @@ |
// Copyright 2014 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
- |
-#include <string> |
#include "base/time/time.h" |
#include "base/values.h" |
@@ -12,18 +10,20 @@ |
namespace cc { |
namespace { |
-static std::string ToString(const RenderingStats::TimeDeltaList& list) { |
- scoped_refptr<base::debug::TracedValue> value = |
- new base::debug::TracedValue(); |
- value->BeginArray("list_value"); |
- list.AddToTracedValue(value.get()); |
- value->EndArray(); |
- return value->ToString(); |
+void CompareDoubleValue(const base::ListValue& list_value, |
+ int index, |
+ double expected_value) { |
+ double value; |
+ EXPECT_TRUE(list_value.GetDouble(index, &value)); |
+ EXPECT_EQ(expected_value, value); |
} |
TEST(RenderingStatsTest, TimeDeltaListEmpty) { |
RenderingStats::TimeDeltaList time_delta_list; |
- EXPECT_EQ("{\"list_value\":[]}", ToString(time_delta_list)); |
+ scoped_ptr<base::ListValue> list_value = |
+ time_delta_list.AsListValueInMilliseconds(); |
+ EXPECT_TRUE(list_value->empty()); |
+ EXPECT_EQ(0ul, list_value->GetSize()); |
} |
TEST(RenderingStatsTest, TimeDeltaListNonEmpty) { |
@@ -31,7 +31,13 @@ |
time_delta_list.Append(base::TimeDelta::FromMilliseconds(234)); |
time_delta_list.Append(base::TimeDelta::FromMilliseconds(827)); |
- EXPECT_EQ("{\"list_value\":[234.0,827.0]}", ToString(time_delta_list)); |
+ scoped_ptr<base::ListValue> list_value = |
+ time_delta_list.AsListValueInMilliseconds(); |
+ EXPECT_FALSE(list_value->empty()); |
+ EXPECT_EQ(2ul, list_value->GetSize()); |
+ |
+ CompareDoubleValue(*list_value.get(), 0, 234); |
+ CompareDoubleValue(*list_value.get(), 1, 827); |
} |
TEST(RenderingStatsTest, TimeDeltaListAdd) { |
@@ -45,8 +51,16 @@ |
time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(2)); |
time_delta_list_a.Add(time_delta_list_b); |
- EXPECT_EQ("{\"list_value\":[810.0,32.0,43.0,938.0,2.0]}", |
- ToString(time_delta_list_a)); |
+ scoped_ptr<base::ListValue> list_value = |
+ time_delta_list_a.AsListValueInMilliseconds(); |
+ EXPECT_FALSE(list_value->empty()); |
+ EXPECT_EQ(5ul, list_value->GetSize()); |
+ |
+ CompareDoubleValue(*list_value.get(), 0, 810); |
+ CompareDoubleValue(*list_value.get(), 1, 32); |
+ CompareDoubleValue(*list_value.get(), 2, 43); |
+ CompareDoubleValue(*list_value.get(), 3, 938); |
+ CompareDoubleValue(*list_value.get(), 4, 2); |
} |
} // namespace |