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

Side by Side Diff: cc/debug/rendering_stats_unittest.cc

Issue 421183003: Revert of Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/debug/rendering_stats.cc ('k') | cc/debug/traced_picture.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string>
6
7 #include "base/time/time.h" 5 #include "base/time/time.h"
8 #include "base/values.h" 6 #include "base/values.h"
9 #include "cc/debug/rendering_stats.h" 7 #include "cc/debug/rendering_stats.h"
10 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
11 9
12 namespace cc { 10 namespace cc {
13 namespace { 11 namespace {
14 12
15 static std::string ToString(const RenderingStats::TimeDeltaList& list) { 13 void CompareDoubleValue(const base::ListValue& list_value,
16 scoped_refptr<base::debug::TracedValue> value = 14 int index,
17 new base::debug::TracedValue(); 15 double expected_value) {
18 value->BeginArray("list_value"); 16 double value;
19 list.AddToTracedValue(value.get()); 17 EXPECT_TRUE(list_value.GetDouble(index, &value));
20 value->EndArray(); 18 EXPECT_EQ(expected_value, value);
21 return value->ToString();
22 } 19 }
23 20
24 TEST(RenderingStatsTest, TimeDeltaListEmpty) { 21 TEST(RenderingStatsTest, TimeDeltaListEmpty) {
25 RenderingStats::TimeDeltaList time_delta_list; 22 RenderingStats::TimeDeltaList time_delta_list;
26 EXPECT_EQ("{\"list_value\":[]}", ToString(time_delta_list)); 23 scoped_ptr<base::ListValue> list_value =
24 time_delta_list.AsListValueInMilliseconds();
25 EXPECT_TRUE(list_value->empty());
26 EXPECT_EQ(0ul, list_value->GetSize());
27 } 27 }
28 28
29 TEST(RenderingStatsTest, TimeDeltaListNonEmpty) { 29 TEST(RenderingStatsTest, TimeDeltaListNonEmpty) {
30 RenderingStats::TimeDeltaList time_delta_list; 30 RenderingStats::TimeDeltaList time_delta_list;
31 time_delta_list.Append(base::TimeDelta::FromMilliseconds(234)); 31 time_delta_list.Append(base::TimeDelta::FromMilliseconds(234));
32 time_delta_list.Append(base::TimeDelta::FromMilliseconds(827)); 32 time_delta_list.Append(base::TimeDelta::FromMilliseconds(827));
33 33
34 EXPECT_EQ("{\"list_value\":[234.0,827.0]}", ToString(time_delta_list)); 34 scoped_ptr<base::ListValue> list_value =
35 time_delta_list.AsListValueInMilliseconds();
36 EXPECT_FALSE(list_value->empty());
37 EXPECT_EQ(2ul, list_value->GetSize());
38
39 CompareDoubleValue(*list_value.get(), 0, 234);
40 CompareDoubleValue(*list_value.get(), 1, 827);
35 } 41 }
36 42
37 TEST(RenderingStatsTest, TimeDeltaListAdd) { 43 TEST(RenderingStatsTest, TimeDeltaListAdd) {
38 RenderingStats::TimeDeltaList time_delta_list_a; 44 RenderingStats::TimeDeltaList time_delta_list_a;
39 time_delta_list_a.Append(base::TimeDelta::FromMilliseconds(810)); 45 time_delta_list_a.Append(base::TimeDelta::FromMilliseconds(810));
40 time_delta_list_a.Append(base::TimeDelta::FromMilliseconds(32)); 46 time_delta_list_a.Append(base::TimeDelta::FromMilliseconds(32));
41 47
42 RenderingStats::TimeDeltaList time_delta_list_b; 48 RenderingStats::TimeDeltaList time_delta_list_b;
43 time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(43)); 49 time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(43));
44 time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(938)); 50 time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(938));
45 time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(2)); 51 time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(2));
46 52
47 time_delta_list_a.Add(time_delta_list_b); 53 time_delta_list_a.Add(time_delta_list_b);
48 EXPECT_EQ("{\"list_value\":[810.0,32.0,43.0,938.0,2.0]}", 54 scoped_ptr<base::ListValue> list_value =
49 ToString(time_delta_list_a)); 55 time_delta_list_a.AsListValueInMilliseconds();
56 EXPECT_FALSE(list_value->empty());
57 EXPECT_EQ(5ul, list_value->GetSize());
58
59 CompareDoubleValue(*list_value.get(), 0, 810);
60 CompareDoubleValue(*list_value.get(), 1, 32);
61 CompareDoubleValue(*list_value.get(), 2, 43);
62 CompareDoubleValue(*list_value.get(), 3, 938);
63 CompareDoubleValue(*list_value.get(), 4, 2);
50 } 64 }
51 65
52 } // namespace 66 } // namespace
53 } // namespace cc 67 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/rendering_stats.cc ('k') | cc/debug/traced_picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698