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

Side by Side Diff: components/browser_watcher/watcher_metrics_provider_win_unittest.cc

Issue 811483006: Don't report exit funnels for live processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « components/browser_watcher/watcher_metrics_provider_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "components/browser_watcher/watcher_metrics_provider_win.h" 5 #include "components/browser_watcher/watcher_metrics_provider_win.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #include "base/process/process_handle.h" 9 #include "base/process/process_handle.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 // Make sure the subkey is deleted on reporting. 132 // Make sure the subkey is deleted on reporting.
133 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); 133 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath);
134 ASSERT_EQ(it.SubkeyCount(), 0); 134 ASSERT_EQ(it.SubkeyCount(), 0);
135 } 135 }
136 136
137 TEST_F(WatcherMetricsProviderWinTest, ReadsExitFunnelWrites) { 137 TEST_F(WatcherMetricsProviderWinTest, ReadsExitFunnelWrites) {
138 // Test that the metrics provider picks up the writes from 138 // Test that the metrics provider picks up the writes from
139 ExitFunnel funnel; 139 ExitFunnel funnel;
140 140
141 // Events against our own process should not get reported.
141 ASSERT_TRUE(funnel.Init(kRegistryPath, base::GetCurrentProcessHandle())); 142 ASSERT_TRUE(funnel.Init(kRegistryPath, base::GetCurrentProcessHandle()));
143 ASSERT_TRUE(funnel.RecordEvent(L"Forgetaboutit"));
144
145 // Reset the funnel to a pseudo process. The PID 4 is the system process,
146 // which tests can hopefully never open.
147 ASSERT_TRUE(funnel.InitImpl(kRegistryPath, 4, base::Time::Now()));
erikwright (departed) 2014/12/19 20:03:38 I don't understand the purpose of this. Is it to t
142 148
143 // Each named event can only exist in a single copy. 149 // Each named event can only exist in a single copy.
144 ASSERT_TRUE(funnel.RecordEvent(L"One")); 150 ASSERT_TRUE(funnel.RecordEvent(L"One"));
145 ASSERT_TRUE(funnel.RecordEvent(L"One")); 151 ASSERT_TRUE(funnel.RecordEvent(L"One"));
146 ASSERT_TRUE(funnel.RecordEvent(L"One")); 152 ASSERT_TRUE(funnel.RecordEvent(L"One"));
147 ASSERT_TRUE(funnel.RecordEvent(L"Two")); 153 ASSERT_TRUE(funnel.RecordEvent(L"Two"));
148 ASSERT_TRUE(funnel.RecordEvent(L"Three")); 154 ASSERT_TRUE(funnel.RecordEvent(L"Three"));
149 155
150 WatcherMetricsProviderWin provider(kRegistryPath); 156 WatcherMetricsProviderWin provider(kRegistryPath);
151 157
152 provider.ProvideStabilityMetrics(NULL); 158 provider.ProvideStabilityMetrics(NULL);
153 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.One", 1); 159 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.One", 1);
154 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Two", 1); 160 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Two", 1);
155 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Three", 1); 161 histogram_tester_.ExpectTotalCount("Stability.ExitFunnel.Three", 1);
156 162
157 // Make sure the subkey has been deleted on reporting. 163 // Make sure the subkey for the pseudo process has been deleted on reporting.
158 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath); 164 base::win::RegistryKeyIterator it(HKEY_CURRENT_USER, kRegistryPath);
159 ASSERT_EQ(it.SubkeyCount(), 0); 165 ASSERT_EQ(it.SubkeyCount(), 1);
160 } 166 }
161 167
162 } // namespace browser_watcher 168 } // namespace browser_watcher
OLDNEW
« no previous file with comments | « components/browser_watcher/watcher_metrics_provider_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698