OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| 11 #include "chrome/common/metrics/variations/variations_associated_data.h" |
11 #include "content/public/browser/user_metrics.h" | 12 #include "content/public/browser/user_metrics.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // The tests that are run by this extension are expected to record the following | 16 // The tests that are run by this extension are expected to record the following |
16 // user actions, with the specified counts. If the tests in test.js are | 17 // user actions, with the specified counts. If the tests in test.js are |
17 // modified, this array may need to be updated. | 18 // modified, this array may need to be updated. |
18 struct RecordedUserAction { | 19 struct RecordedUserAction { |
19 const char* name; | 20 const char* name; |
20 int count; // number of times the metric was recorded. | 21 int count; // number of times the metric was recorded. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 123 } |
123 } | 124 } |
124 | 125 |
125 } // anonymous namespace | 126 } // anonymous namespace |
126 | 127 |
127 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics) { | 128 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics) { |
128 UserActionObserver observer; | 129 UserActionObserver observer; |
129 | 130 |
130 base::FieldTrialList::CreateFieldTrial("apitestfieldtrial2", "group1"); | 131 base::FieldTrialList::CreateFieldTrial("apitestfieldtrial2", "group1"); |
131 | 132 |
| 133 std::map<std::string, std::string> params; |
| 134 params["a"] = "aa"; |
| 135 params["b"] = "bb"; |
| 136 ASSERT_TRUE(chrome_variations::AssociateVariationParams( |
| 137 "apitestfieldtrial2", "group1", params)); |
| 138 |
132 ASSERT_TRUE(RunComponentExtensionTest("metrics")) << message_; | 139 ASSERT_TRUE(RunComponentExtensionTest("metrics")) << message_; |
133 | 140 |
134 observer.ValidateUserActions(g_user_actions, arraysize(g_user_actions)); | 141 observer.ValidateUserActions(g_user_actions, arraysize(g_user_actions)); |
135 ValidateHistograms(g_histograms, arraysize(g_histograms)); | 142 ValidateHistograms(g_histograms, arraysize(g_histograms)); |
136 } | 143 } |
OLD | NEW |