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

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

Issue 412143009: Moved data reduction proxy initialization logic to ProfileImplIOData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 6 years, 4 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
« no previous file with comments | « components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 39a951fc9442e341a509a2027b732b1202c13665..33142534aeadb3fa401cca597a3418c4c16937df 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
@@ -4,6 +4,7 @@
#include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h"
+#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "net/base/request_priority.h"
#include "net/url_request/url_request.h"
@@ -45,9 +46,15 @@ class DataReductionProxyUsageStatsTest : public testing::Test {
DataReductionProxyUsageStatsTest()
: loop_proxy_(MessageLoopProxy::current().get()),
context_(true),
- mock_url_request_(GURL(), net::IDLE, &delegate_, &context_) {
+ mock_url_request_(GURL(), net::IDLE, &delegate_, &context_),
+ unavailable_(false) {
context_.Init();
}
+
+ void NotifyUnavailable(bool unavailable) {
+ unavailable_ = unavailable;
+ }
+
// Required for MessageLoopProxy::current().
base::MessageLoopForUI loop_;
MessageLoopProxy* loop_proxy_;
@@ -57,9 +64,10 @@ class DataReductionProxyUsageStatsTest : public testing::Test {
TestDelegate delegate_;
DataReductionProxyParamsMock mock_params_;
URLRequest mock_url_request_;
+ bool unavailable_;
};
-TEST_F(DataReductionProxyUsageStatsTest, isDataReductionProxyUnreachable) {
+TEST_F(DataReductionProxyUsageStatsTest, IsDataReductionProxyUnreachable) {
struct TestCase {
bool is_proxy_eligible;
bool was_proxy_used;
@@ -93,13 +101,15 @@ TEST_F(DataReductionProxyUsageStatsTest, isDataReductionProxyUnreachable) {
scoped_ptr<DataReductionProxyUsageStats> usage_stats(
new DataReductionProxyUsageStats(
- &mock_params_, loop_proxy_, loop_proxy_));
+ &mock_params_, loop_proxy_));
+ usage_stats->set_unavailable_callback(
+ base::Bind(&DataReductionProxyUsageStatsTest::NotifyUnavailable,
+ base::Unretained(this)));
usage_stats->OnUrlRequestCompleted(&mock_url_request_, false);
MessageLoop::current()->RunUntilIdle();
- EXPECT_EQ(test_case.is_unreachable,
- usage_stats->isDataReductionProxyUnreachable());
+ EXPECT_EQ(test_case.is_unreachable, unavailable_);
}
}
« no previous file with comments | « components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698