Update V8 to version 4.7.21.
[chromium-blink-merge.git] / ppapi / tests / test_uma.cc
blobc7bdbde4a8f21ccc21578ea1d7b9e2d2dde27045
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
3 // found in the LICENSE file.
5 #include "ppapi/tests/test_uma.h"
7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/tests/testing_instance.h"
11 REGISTER_TEST_CASE(UMA);
13 bool TestUMA::Init() {
14 uma_interface_ = static_cast<const PPB_UMA_Private*>(
15 pp::Module::Get()->GetBrowserInterface(PPB_UMA_PRIVATE_INTERFACE));
16 return !!uma_interface_;
19 void TestUMA::RunTests(const std::string& filter) {
20 RUN_TEST(Count, filter);
21 RUN_TEST(Time, filter);
22 RUN_TEST(Enum, filter);
25 std::string TestUMA::TestCount() {
26 pp::Var name_var = pp::Var("Test.CountHistogram");
27 PP_Var name = name_var.pp_var();
28 PP_Instance instance = instance_->pp_instance();
29 uma_interface_->HistogramCustomCounts(instance, name, 10, 1, 100, 50);
30 uma_interface_->HistogramCustomCounts(instance, name, 30, 1, 100, 50);
31 uma_interface_->HistogramCustomCounts(instance, name, 20, 1, 100, 50);
32 uma_interface_->HistogramCustomCounts(instance, name, 40, 1, 100, 50);
33 // Test that passing in different construction arguments for the same
34 // histogram name does not crash.
35 uma_interface_->HistogramCustomCounts(instance, name, 40, 1, 100, 100);
36 uma_interface_->HistogramCustomCounts(instance, name, 40, 1, 90, 50);
37 uma_interface_->HistogramCustomCounts(instance, name, 40, 10, 100, 50);
38 PASS();
41 std::string TestUMA::TestTime() {
42 pp::Var name_var = pp::Var("Test.TimeHistogram");
43 PP_Var name = name_var.pp_var();
44 PP_Instance instance = instance_->pp_instance();
45 uma_interface_->HistogramCustomTimes(instance, name, 100, 1, 10000, 50);
46 uma_interface_->HistogramCustomTimes(instance, name, 1000, 1, 10000, 50);
47 uma_interface_->HistogramCustomTimes(instance, name, 5000, 1, 10000, 50);
48 uma_interface_->HistogramCustomTimes(instance, name, 10, 1, 10000, 50);
49 // Test that passing in different construction arguments for the same
50 // histogram name does not crash.
51 uma_interface_->HistogramCustomTimes(instance, name, 10, 1, 10000, 100);
52 uma_interface_->HistogramCustomTimes(instance, name, 10, 1, 9000, 50);
53 uma_interface_->HistogramCustomTimes(instance, name, 10, 100, 10000, 50);
54 PASS();
57 std::string TestUMA::TestEnum() {
58 pp::Var name_var = pp::Var("Test.EnumHistogram");
59 PP_Var name = name_var.pp_var();
60 PP_Instance instance = instance_->pp_instance();
61 uma_interface_->HistogramEnumeration(instance, name, 0, 5);
62 uma_interface_->HistogramEnumeration(instance, name, 3, 5);
63 uma_interface_->HistogramEnumeration(instance, name, 3, 5);
64 uma_interface_->HistogramEnumeration(instance, name, 1, 5);
65 uma_interface_->HistogramEnumeration(instance, name, 2, 5);
66 // Test that passing in different construction arguments for the same
67 // histogram name does not crash.
68 uma_interface_->HistogramEnumeration(instance, name, 2, 6);
69 PASS();