| Index: net/base/sdch_manager_unittest.cc
|
| diff --git a/net/base/sdch_manager_unittest.cc b/net/base/sdch_manager_unittest.cc
|
| index 40b55c671ec4bf7543092a7a5bd130d0d234a197..d986879aaa4c9b9928039f3290731e5ca49f0b0f 100644
|
| --- a/net/base/sdch_manager_unittest.cc
|
| +++ b/net/base/sdch_manager_unittest.cc
|
| @@ -9,15 +9,13 @@
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "net/base/sdch_manager.h"
|
| +#include "net/base/sdch_observer.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "url/gurl.h"
|
|
|
| namespace net {
|
|
|
| //------------------------------------------------------------------------------
|
| -// Workaround for http://crbug.com/418975; remove when fixed.
|
| -#if !defined(OS_IOS)
|
| -
|
| -//------------------------------------------------------------------------------
|
| // Provide sample data and compression results with a sample VCDIFF dictionary.
|
| // Note an SDCH dictionary has extra meta-data before the VCDIFF dictionary.
|
| static const char kTestVcdiffDictionary[] = "DictionaryFor"
|
| @@ -25,6 +23,32 @@ static const char kTestVcdiffDictionary[] = "DictionaryFor"
|
|
|
| //------------------------------------------------------------------------------
|
|
|
| +class MockSdchObserver : public SdchObserver {
|
| + public:
|
| + MockSdchObserver() : get_dictionary_notifications_(0) {}
|
| +
|
| + const GURL& last_dictionary_request_url() {
|
| + return last_dictionary_request_url_;
|
| + }
|
| + const GURL& last_dictionary_url() { return last_dictionary_url_; }
|
| + int get_dictionary_notifications() { return get_dictionary_notifications_; }
|
| +
|
| + // SdchObserver implementation
|
| + void OnGetDictionary(SdchManager* manager,
|
| + const GURL& request_url,
|
| + const GURL& dictionary_url) override {
|
| + ++get_dictionary_notifications_;
|
| + last_dictionary_request_url_ = request_url;
|
| + last_dictionary_url_ = dictionary_url;
|
| + }
|
| + void OnClearDictionaries(SdchManager* manager) override {}
|
| +
|
| + private:
|
| + int get_dictionary_notifications_;
|
| + GURL last_dictionary_request_url_;
|
| + GURL last_dictionary_url_;
|
| +};
|
| +
|
| class SdchManagerTest : public testing::Test {
|
| protected:
|
| SdchManagerTest()
|
| @@ -35,6 +59,8 @@ class SdchManagerTest : public testing::Test {
|
| default_https_support_ = sdch_manager_->secure_scheme_supported();
|
| }
|
|
|
| + virtual ~SdchManagerTest() {}
|
| +
|
| SdchManager* sdch_manager() { return sdch_manager_.get(); }
|
|
|
| // Reset globals back to default state.
|
| @@ -521,12 +547,7 @@ TEST_F(SdchManagerTest, HttpsCorrectlySupported) {
|
| GURL url("http://www.google.com");
|
| GURL secure_url("https://www.google.com");
|
|
|
| -#if !defined(OS_IOS)
|
| - // Workaround for http://crbug.com/418975; remove when fixed.
|
| bool expect_https_support = true;
|
| -#else
|
| - bool expect_https_support = false;
|
| -#endif
|
|
|
| EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(url));
|
| EXPECT_EQ(expect_https_support,
|
| @@ -572,17 +593,23 @@ TEST_F(SdchManagerTest, ClearDictionaryData) {
|
| EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url));
|
| }
|
|
|
| -#else
|
| -
|
| -TEST(SdchManagerTest, SdchOffByDefault) {
|
| - GURL google_url("http://www.google.com");
|
| - SdchManager* sdch_manager(new SdchManager);
|
| -
|
| - EXPECT_FALSE(sdch_manager->IsInSupportedDomain(google_url));
|
| - SdchManager::EnableSdchSupport(true);
|
| - EXPECT_TRUE(sdch_manager->IsInSupportedDomain(google_url));
|
| +TEST_F(SdchManagerTest, GetDictionaryNotification) {
|
| + GURL test_request_gurl(GURL("http://www.example.com/data"));
|
| + GURL test_dictionary_gurl(GURL("http://www.example.com/dict"));
|
| + MockSdchObserver observer;
|
| + sdch_manager()->AddObserver(&observer);
|
| +
|
| + EXPECT_EQ(0, observer.get_dictionary_notifications());
|
| + sdch_manager()->OnGetDictionary(test_request_gurl, test_dictionary_gurl);
|
| + EXPECT_EQ(1, observer.get_dictionary_notifications());
|
| + EXPECT_EQ(test_request_gurl, observer.last_dictionary_request_url());
|
| + EXPECT_EQ(test_dictionary_gurl, observer.last_dictionary_url());
|
| +
|
| + sdch_manager()->RemoveObserver(&observer);
|
| + sdch_manager()->OnGetDictionary(test_request_gurl, test_dictionary_gurl);
|
| + EXPECT_EQ(1, observer.get_dictionary_notifications());
|
| + EXPECT_EQ(test_request_gurl, observer.last_dictionary_request_url());
|
| + EXPECT_EQ(test_dictionary_gurl, observer.last_dictionary_url());
|
| }
|
|
|
| -#endif // !defined(OS_IOS)
|
| -
|
| } // namespace net
|
|
|