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

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats_unittest.cc

Issue 568893002: Trigger data reduction proxy unreachable message via on proxy fall back. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats_unittest.cc
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats_unittest.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats_unittest.cc
index e522a95f40892f89b50f81391f6a18320a066225..6934ee25bc610500a9bd348f46192f6b5b2fe3c2 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats_unittest.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats_unittest.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
+#include "net/base/host_port_pair.h"
#include "net/base/request_priority.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_status.h"
@@ -16,10 +17,14 @@
using base::MessageLoop;
using base::MessageLoopProxy;
using data_reduction_proxy::DataReductionProxyParams;
+using data_reduction_proxy::DataReductionProxyTypeInfo;
+using net::HostPortPair;
bengr 2014/09/16 18:48:57 If you have this line here, then you don't need to
Not at Google. Contact bengr 2014/09/16 19:34:49 Done.
+using net::ProxyServer;
using net::TestDelegate;
using net::TestURLRequestContext;
using net::URLRequest;
using net::URLRequestStatus;
+using testing::_;
using testing::Return;
namespace {
@@ -29,11 +34,14 @@ class DataReductionProxyParamsMock : public DataReductionProxyParams {
DataReductionProxyParamsMock() : DataReductionProxyParams(0) {}
virtual ~DataReductionProxyParamsMock() {}
- MOCK_METHOD1(IsDataReductionProxyEligible, bool(const net::URLRequest*));
+ MOCK_CONST_METHOD2(
+ IsDataReductionProxy,
+ bool(const net::HostPortPair& host_port_pair,
+ data_reduction_proxy::DataReductionProxyTypeInfo* proxy_info));
MOCK_CONST_METHOD2(
WasDataReductionProxyUsed,
bool(const net::URLRequest*,
- data_reduction_proxy::DataReductionProxyTypeInfo* proxy_servers));
+ data_reduction_proxy::DataReductionProxyTypeInfo* proxy_info));
private:
DISALLOW_COPY_AND_ASSIGN(DataReductionProxyParamsMock);
@@ -43,6 +51,7 @@ class DataReductionProxyParamsMock : public DataReductionProxyParams {
namespace data_reduction_proxy {
+
class DataReductionProxyUsageStatsTest : public testing::Test {
public:
DataReductionProxyUsageStatsTest()
@@ -71,8 +80,11 @@ class DataReductionProxyUsageStatsTest : public testing::Test {
};
TEST_F(DataReductionProxyUsageStatsTest, IsDataReductionProxyUnreachable) {
+ ProxyServer fallback_proxy_server =
+ ProxyServer::FromURI("foo.com", ProxyServer::SCHEME_HTTP);
+ DataReductionProxyTypeInfo proxy_info;
struct TestCase {
- bool is_proxy_eligible;
+ bool fallback_proxy_server_is_data_reduction_proxy;
bool was_proxy_used;
bool is_unreachable;
};
@@ -83,6 +95,11 @@ TEST_F(DataReductionProxyUsageStatsTest, IsDataReductionProxyUnreachable) {
false
},
{
+ false,
+ true,
+ false
+ },
+ {
true,
true,
false
@@ -96,9 +113,9 @@ TEST_F(DataReductionProxyUsageStatsTest, IsDataReductionProxyUnreachable) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
TestCase test_case = test_cases[i];
- EXPECT_CALL(mock_params_,
- IsDataReductionProxyEligible(mock_url_request_.get()))
- .WillRepeatedly(Return(test_case.is_proxy_eligible));
+ EXPECT_CALL(mock_params_, IsDataReductionProxy(_, _))
+ .WillRepeatedly(
+ Return(test_case.fallback_proxy_server_is_data_reduction_proxy));
EXPECT_CALL(mock_params_,
WasDataReductionProxyUsed(mock_url_request_.get(), NULL))
.WillRepeatedly(Return(test_case.was_proxy_used));
@@ -110,6 +127,8 @@ TEST_F(DataReductionProxyUsageStatsTest, IsDataReductionProxyUnreachable) {
base::Bind(&DataReductionProxyUsageStatsTest::NotifyUnavailable,
base::Unretained(this)));
+ usage_stats->OnProxyFallback(fallback_proxy_server,
+ net::ERR_PROXY_CONNECTION_FAILED);
usage_stats->OnUrlRequestCompleted(mock_url_request_.get(), false);
MessageLoop::current()->RunUntilIdle();

Powered by Google App Engine
This is Rietveld 408576698