- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / tests / test_uma.cc
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.
4
5 #include "ppapi/tests/test_uma.h"
6
7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/tests/testing_instance.h"
10
11 REGISTER_TEST_CASE(UMA);
12
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_;
17 }
18
19 void TestUMA::RunTests(const std::string& filter) {
20   RUN_TEST(Count, filter);
21   RUN_TEST(Time, filter);
22   RUN_TEST(Enum, filter);
23 }
24
25 std::string TestUMA::TestCount() {
26   pp::Var name_var = pp::Var("Test.CountHistogram");
27   PP_Var name = name_var.pp_var();
28   uma_interface_->HistogramCustomCounts(name, 10, 1, 100, 50);
29   uma_interface_->HistogramCustomCounts(name, 30, 1, 100, 50);
30   uma_interface_->HistogramCustomCounts(name, 20, 1, 100, 50);
31   uma_interface_->HistogramCustomCounts(name, 40, 1, 100, 50);
32   PASS();
33 }
34
35 std::string TestUMA::TestTime() {
36   pp::Var name_var = pp::Var("Test.TimeHistogram");
37   PP_Var name = name_var.pp_var();
38   uma_interface_->HistogramCustomTimes(name, 100, 1, 10000, 50);
39   uma_interface_->HistogramCustomTimes(name, 1000, 1, 10000, 50);
40   uma_interface_->HistogramCustomTimes(name, 5000, 1, 10000, 50);
41   uma_interface_->HistogramCustomTimes(name, 10, 1, 10000, 50);
42   PASS();
43 }
44
45 std::string TestUMA::TestEnum() {
46   pp::Var name_var = pp::Var("Test.EnumHistogram");
47   PP_Var name = name_var.pp_var();
48   uma_interface_->HistogramEnumeration(name, 0, 5);
49   uma_interface_->HistogramEnumeration(name, 3, 5);
50   uma_interface_->HistogramEnumeration(name, 3, 5);
51   uma_interface_->HistogramEnumeration(name, 1, 5);
52   uma_interface_->HistogramEnumeration(name, 2, 5);
53   PASS();
54 }
55