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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc

Issue 602503002: Adds UMA to measure when the data reduction proxy via header is missing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove DCHECKs from tests Created 6 years, 2 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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/data_reduction_proxy/browser/data_reduction_proxy_settings_ test_utils.h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings_ test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/scoped_user_pref_update.h" 11 #include "base/prefs/scoped_user_pref_update.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/test/test_simple_task_runner.h" 13 #include "base/test/test_simple_task_runner.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" 15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h"
16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_statistic s_prefs.h" 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_statistic s_prefs.h"
17 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers_te st_utils.h"
17 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names .h" 18 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names .h"
18 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " 19 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h "
19 20
20 using testing::_; 21 using testing::_;
21 using testing::AnyNumber; 22 using testing::AnyNumber;
22 using testing::Return; 23 using testing::Return;
23 24
24 namespace { 25 namespace {
25 26
26 const char kProbeURLWithOKResponse[] = "http://ok.org/"; 27 const char kProbeURLWithOKResponse[] = "http://ok.org/";
27 28
28 const char kProxy[] = "proxy"; 29 const char kProxy[] = "proxy";
29 30
30 } // namespace 31 } // namespace
31 32
32 namespace data_reduction_proxy { 33 namespace data_reduction_proxy {
33 34
34 // Transform "normal"-looking headers (\n-separated) to the appropriate
35 // input format for ParseRawHeaders (\0-separated).
36 void HeadersToRaw(std::string* headers) {
37 std::replace(headers->begin(), headers->end(), '\n', '\0');
38 if (!headers->empty())
39 *headers += '\0';
40 }
41
42 ProbeURLFetchResult FetchResult(bool enabled, bool success) { 35 ProbeURLFetchResult FetchResult(bool enabled, bool success) {
43 if (enabled) { 36 if (enabled) {
44 if (success) 37 if (success)
45 return SUCCEEDED_PROXY_ALREADY_ENABLED; 38 return SUCCEEDED_PROXY_ALREADY_ENABLED;
46 return FAILED_PROXY_DISABLED; 39 return FAILED_PROXY_DISABLED;
47 } 40 }
48 if (success) 41 if (success)
49 return SUCCEEDED_PROXY_ENABLED; 42 return SUCCEEDED_PROXY_ENABLED;
50 return FAILED_PROXY_ALREADY_DISABLED; 43 return FAILED_PROXY_ALREADY_DISABLED;
51 } 44 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 base::Bind(&DataReductionProxySettingsTestBase:: 293 base::Bind(&DataReductionProxySettingsTestBase::
301 RegisterSyntheticFieldTrialCallback, 294 RegisterSyntheticFieldTrialCallback,
302 base::Unretained(this))); 295 base::Unretained(this)));
303 296
304 base::MessageLoop::current()->RunUntilIdle(); 297 base::MessageLoop::current()->RunUntilIdle();
305 CheckProxyConfigs(enabled_at_startup, false, false); 298 CheckProxyConfigs(enabled_at_startup, false, false);
306 EXPECT_EQ(enabled_at_startup, proxy_enabled_); 299 EXPECT_EQ(enabled_at_startup, proxy_enabled_);
307 } 300 }
308 301
309 } // namespace data_reduction_proxy 302 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698