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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest_android.cc

Issue 105833010: Added Dev host for data reduction proxy controlled by Finch experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync to head. Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/prefs/scoped_user_pref_update.h" 14 #include "base/prefs/scoped_user_pref_update.h"
15 #include "base/prefs/testing_pref_service.h" 15 #include "base/prefs/testing_pref_service.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h" 17 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h"
18 #include "chrome/browser/prefs/proxy_prefs.h" 18 #include "chrome/browser/prefs/proxy_prefs.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/metrics/variations/variations_util.h" 20 #include "chrome/common/metrics/variations/variations_util.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "components/variations/entropy_provider.h" 22 #include "components/variations/entropy_provider.h"
23 #include "net/url_request/test_url_fetcher_factory.h" 23 #include "net/url_request/test_url_fetcher_factory.h"
24 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 const char kDataReductionProxyOrigin[] = "https://foo.com:443/"; 28 const char kDataReductionProxyOrigin[] = "https://foo.com:443/";
29 const char kDataReductionProxyDevHost[] = "http://foo-dev.com:80";
29 const char kDataReductionProxyOriginPAC[] = "HTTPS foo.com:443;"; 30 const char kDataReductionProxyOriginPAC[] = "HTTPS foo.com:443;";
30 const char kDataReductionProxyFallbackPAC[] = "PROXY bar.com:80;"; 31 const char kDataReductionProxyFallbackPAC[] = "PROXY bar.com:80;";
31 32
32 class DataReductionProxySettingsAndroidTest 33 class DataReductionProxySettingsAndroidTest
33 : public ConcreteDataReductionProxySettingsTest< 34 : public ConcreteDataReductionProxySettingsTest<
34 DataReductionProxySettingsAndroid> { 35 DataReductionProxySettingsAndroid> {
35 public: 36 public:
36 // DataReductionProxySettingsTest implementation: 37 // DataReductionProxySettingsTest implementation:
37 virtual void SetUp() OVERRIDE { 38 virtual void SetUp() OVERRIDE {
38 env_ = base::android::AttachCurrentThread(); 39 env_ = base::android::AttachCurrentThread();
(...skipping 23 matching lines...) Expand all
62 TEST_F(DataReductionProxySettingsAndroidTest, TestGetDataReductionProxyOrigin) { 63 TEST_F(DataReductionProxySettingsAndroidTest, TestGetDataReductionProxyOrigin) {
63 AddProxyToCommandLine(); 64 AddProxyToCommandLine();
64 // SetUp() adds the origin to the command line, which should be returned here. 65 // SetUp() adds the origin to the command line, which should be returned here.
65 ScopedJavaLocalRef<jstring> result = 66 ScopedJavaLocalRef<jstring> result =
66 Settings()->GetDataReductionProxyOrigin(env_, NULL); 67 Settings()->GetDataReductionProxyOrigin(env_, NULL);
67 ASSERT_TRUE(result.obj()); 68 ASSERT_TRUE(result.obj());
68 const base::android::JavaRef<jstring>& str_ref = result; 69 const base::android::JavaRef<jstring>& str_ref = result;
69 EXPECT_EQ(kDataReductionProxyOrigin, ConvertJavaStringToUTF8(str_ref)); 70 EXPECT_EQ(kDataReductionProxyOrigin, ConvertJavaStringToUTF8(str_ref));
70 } 71 }
71 72
73 TEST_F(DataReductionProxySettingsAndroidTest,
74 TestGetDataReductionProxyDevOrigin) {
75 AddProxyToCommandLine();
76 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
77 switches::kSpdyProxyDevAuthOrigin, kDataReductionProxyDevHost);
78 ScopedJavaLocalRef<jstring> result =
79 Settings()->GetDataReductionProxyOrigin(env_, NULL);
80 ASSERT_TRUE(result.obj());
81 const base::android::JavaRef<jstring>& str_ref = result;
82 EXPECT_EQ(kDataReductionProxyDevHost, ConvertJavaStringToUTF8(str_ref));
83 }
84
72 // Confirm that the bypass rule functions generate the intended JavaScript 85 // Confirm that the bypass rule functions generate the intended JavaScript
73 // code for the Proxy PAC. 86 // code for the Proxy PAC.
74 TEST_F(DataReductionProxySettingsAndroidTest, TestBypassPACRules) { 87 TEST_F(DataReductionProxySettingsAndroidTest, TestBypassPACRules) {
75 Settings()->AddURLPatternToBypass("http://foo.com/*"); 88 Settings()->AddURLPatternToBypass("http://foo.com/*");
76 Settings()->AddHostPatternToBypass("bar.com"); 89 Settings()->AddHostPatternToBypass("bar.com");
77 90
78 EXPECT_EQ(Settings()->pac_bypass_rules_.size(), 1u); 91 EXPECT_EQ(Settings()->pac_bypass_rules_.size(), 1u);
79 EXPECT_EQ("shExpMatch(url, 'http://foo.com/*')", 92 EXPECT_EQ("shExpMatch(url, 'http://foo.com/*')",
80 Settings()->pac_bypass_rules_[0]); 93 Settings()->pac_bypass_rules_[0]);
81 94
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 ASSERT_EQ(static_cast<jsize>(spdyproxy::kNumDaysInHistory), java_array_len); 140 ASSERT_EQ(static_cast<jsize>(spdyproxy::kNumDaysInHistory), java_array_len);
128 141
129 jlong value; 142 jlong value;
130 for (size_t i = 0; i < spdyproxy::kNumDaysInHistory; ++i) { 143 for (size_t i = 0; i < spdyproxy::kNumDaysInHistory; ++i) {
131 env_->GetLongArrayRegion(result.obj(), i, 1, &value); 144 env_->GetLongArrayRegion(result.obj(), i, 1, &value);
132 ASSERT_EQ( 145 ASSERT_EQ(
133 static_cast<long>((spdyproxy::kNumDaysInHistory - 1 - i) * 2), value); 146 static_cast<long>((spdyproxy::kNumDaysInHistory - 1 - i) * 2), value);
134 } 147 }
135 } 148 }
136 149
OLDNEW
« no previous file with comments | « chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698