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

Unified Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc

Issue 1406993010: Crop urls in Data Saver feedback reports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/core/common/data_reduction_proxy_event_store_unittest.cc
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc
index 077f957017a6d45abf7f8f97db3625ad640dedad..86d1dbd81d3c6cbbf03ca066bd033480c8d701e3 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
+#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h"
@@ -229,13 +230,25 @@ TEST_F(DataReductionProxyEventStoreTest, TestFeedbackMethods) {
event_store()->GetHttpProxyList());
EXPECT_EQ("baz.com:80", event_store()->GetHttpsProxyList());
+ configurator.Disable();
+ EXPECT_EQ(std::string(), event_store()->GetHttpProxyList());
+ EXPECT_EQ(std::string(), event_store()->GetHttpsProxyList());
+}
+
+TEST_F(DataReductionProxyEventStoreTest, TestFeedbackLastBypassEventFullURL) {
+ DataReductionProxyConfigurator configurator(net_log(), event_creator());
+ std::vector<net::ProxyServer> http_proxies;
+ std::vector<net::ProxyServer> https_proxies;
+ configurator.Enable(false, http_proxies, https_proxies);
+
scoped_ptr<base::DictionaryValue> bypass_event(new base::DictionaryValue());
scoped_ptr<base::DictionaryValue> bypass_params(new base::DictionaryValue());
scoped_ptr<base::DictionaryValue> sanitized_event(
new base::DictionaryValue());
- bypass_event->SetString("time", "12/31/2014 23:58");
- sanitized_event->SetString("bypass_time", "12/31/2014 23:58");
+ std::string time = net::NetLog::TickCountToString(base::TimeTicks::Now());
+ bypass_event->SetString("time", time);
+ sanitized_event->SetString("bypass_time", time);
bypass_params->SetInteger("bypass_type", 4);
sanitized_event->SetInteger("bypass_type", 4);
bypass_params->SetString("bypass_duration_seconds", "40");
@@ -248,10 +261,38 @@ TEST_F(DataReductionProxyEventStoreTest, TestFeedbackMethods) {
base::JSONWriter::Write(*sanitized_event.get(), &sanitized_output);
event_store()->AddAndSetLastBypassEvent(bypass_event.Pass(), 0);
EXPECT_EQ(sanitized_output, event_store()->SanitizedLastBypassEvent());
+}
- configurator.Disable();
- EXPECT_EQ(std::string(), event_store()->GetHttpProxyList());
- EXPECT_EQ(std::string(), event_store()->GetHttpsProxyList());
+TEST_F(DataReductionProxyEventStoreTest, TestFeedbackLastBypassEventHostOnly) {
+ DataReductionProxyConfigurator configurator(net_log(), event_creator());
+ std::vector<net::ProxyServer> http_proxies;
+ std::vector<net::ProxyServer> https_proxies;
+ configurator.Enable(false, http_proxies, https_proxies);
+
+ scoped_ptr<base::DictionaryValue> bypass_event(new base::DictionaryValue());
+ scoped_ptr<base::DictionaryValue> bypass_params(new base::DictionaryValue());
+ scoped_ptr<base::DictionaryValue> sanitized_event(
+ new base::DictionaryValue());
+
+ int64 delta_time =
+ (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds();
+ // Set bypass event time to be 5 minutes ago.
+ delta_time -= 300000;
+ std::string time = base::Int64ToString(delta_time);
+ bypass_event->SetString("time", time);
+ sanitized_event->SetString("bypass_time", time);
+ bypass_params->SetInteger("bypass_type", 4);
+ sanitized_event->SetInteger("bypass_type", 4);
+ bypass_params->SetString("bypass_duration_seconds", "40");
+ sanitized_event->SetString("bypass_seconds", "40");
+ bypass_params->SetString("url", "http://www.foo.com/bar?baz=1234");
+ sanitized_event->SetString("url", "www.foo.com");
+
+ bypass_event->Set("params", bypass_params.Pass());
+ std::string sanitized_output;
+ base::JSONWriter::Write(*sanitized_event.get(), &sanitized_output);
+ event_store()->AddAndSetLastBypassEvent(bypass_event.Pass(), 0);
+ EXPECT_EQ(sanitized_output, event_store()->SanitizedLastBypassEvent());
}
} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698