OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/tests/test_uma.h" | 5 #include "ppapi/tests/test_uma.h" |
6 | 6 |
7 #include "ppapi/cpp/instance.h" | 7 #include "ppapi/cpp/instance.h" |
8 #include "ppapi/cpp/module.h" | 8 #include "ppapi/cpp/module.h" |
9 #include "ppapi/tests/testing_instance.h" | 9 #include "ppapi/tests/testing_instance.h" |
10 | 10 |
11 REGISTER_TEST_CASE(UMA); | 11 REGISTER_TEST_CASE(UMA); |
12 | 12 |
13 bool TestUMA::Init() { | 13 bool TestUMA::Init() { |
14 uma_interface_ = static_cast<const PPB_UMA_Private*>( | 14 uma_interface_ = static_cast<const PPB_UMA_Private*>( |
15 pp::Module::Get()->GetBrowserInterface(PPB_UMA_PRIVATE_INTERFACE)); | 15 pp::Module::Get()->GetBrowserInterface(PPB_UMA_PRIVATE_INTERFACE)); |
16 return !!uma_interface_; | 16 return !!uma_interface_; |
17 } | 17 } |
18 | 18 |
19 void TestUMA::RunTests(const std::string& filter) { | 19 void TestUMA::RunTests(const std::string& filter) { |
20 RUN_TEST(Count, filter); | 20 RUN_TEST(Count, filter); |
21 RUN_TEST(Time, filter); | 21 RUN_TEST(Time, filter); |
22 RUN_TEST(Enum, filter); | 22 RUN_TEST(Enum, filter); |
23 } | 23 } |
24 | 24 |
25 std::string TestUMA::TestCount() { | 25 std::string TestUMA::TestCount() { |
26 pp::Var name_var = pp::Var("Test.CountHistogram"); | 26 pp::Var name_var = pp::Var("Test.CountHistogram"); |
27 PP_Var name = name_var.pp_var(); | 27 PP_Var name = name_var.pp_var(); |
28 uma_interface_->HistogramCustomCounts(name, 10, 1, 100, 50); | 28 PP_Instance instance = instance_->pp_instance(); |
29 uma_interface_->HistogramCustomCounts(name, 30, 1, 100, 50); | 29 uma_interface_->HistogramCustomCounts(instance, name, 10, 1, 100, 50); |
30 uma_interface_->HistogramCustomCounts(name, 20, 1, 100, 50); | 30 uma_interface_->HistogramCustomCounts(instance, name, 30, 1, 100, 50); |
31 uma_interface_->HistogramCustomCounts(name, 40, 1, 100, 50); | 31 uma_interface_->HistogramCustomCounts(instance, name, 20, 1, 100, 50); |
| 32 uma_interface_->HistogramCustomCounts(instance, name, 40, 1, 100, 50); |
32 PASS(); | 33 PASS(); |
33 } | 34 } |
34 | 35 |
35 std::string TestUMA::TestTime() { | 36 std::string TestUMA::TestTime() { |
36 pp::Var name_var = pp::Var("Test.TimeHistogram"); | 37 pp::Var name_var = pp::Var("Test.TimeHistogram"); |
37 PP_Var name = name_var.pp_var(); | 38 PP_Var name = name_var.pp_var(); |
38 uma_interface_->HistogramCustomTimes(name, 100, 1, 10000, 50); | 39 PP_Instance instance = instance_->pp_instance(); |
39 uma_interface_->HistogramCustomTimes(name, 1000, 1, 10000, 50); | 40 uma_interface_->HistogramCustomTimes(instance, name, 100, 1, 10000, 50); |
40 uma_interface_->HistogramCustomTimes(name, 5000, 1, 10000, 50); | 41 uma_interface_->HistogramCustomTimes(instance, name, 1000, 1, 10000, 50); |
41 uma_interface_->HistogramCustomTimes(name, 10, 1, 10000, 50); | 42 uma_interface_->HistogramCustomTimes(instance, name, 5000, 1, 10000, 50); |
| 43 uma_interface_->HistogramCustomTimes(instance, name, 10, 1, 10000, 50); |
42 PASS(); | 44 PASS(); |
43 } | 45 } |
44 | 46 |
45 std::string TestUMA::TestEnum() { | 47 std::string TestUMA::TestEnum() { |
46 pp::Var name_var = pp::Var("Test.EnumHistogram"); | 48 pp::Var name_var = pp::Var("Test.EnumHistogram"); |
47 PP_Var name = name_var.pp_var(); | 49 PP_Var name = name_var.pp_var(); |
48 uma_interface_->HistogramEnumeration(name, 0, 5); | 50 PP_Instance instance = instance_->pp_instance(); |
49 uma_interface_->HistogramEnumeration(name, 3, 5); | 51 uma_interface_->HistogramEnumeration(instance, name, 0, 5); |
50 uma_interface_->HistogramEnumeration(name, 3, 5); | 52 uma_interface_->HistogramEnumeration(instance, name, 3, 5); |
51 uma_interface_->HistogramEnumeration(name, 1, 5); | 53 uma_interface_->HistogramEnumeration(instance, name, 3, 5); |
52 uma_interface_->HistogramEnumeration(name, 2, 5); | 54 uma_interface_->HistogramEnumeration(instance, name, 1, 5); |
| 55 uma_interface_->HistogramEnumeration(instance, name, 2, 5); |
53 PASS(); | 56 PASS(); |
54 } | 57 } |
55 | 58 |
OLD | NEW |