| Index: net/base/sdch_manager_unittest.cc
|
| diff --git a/net/base/sdch_manager_unittest.cc b/net/base/sdch_manager_unittest.cc
|
| index f6d44bebb8595cdebfb93475044423143f4f3c94..f5d7f6b1f2e45eca05e9f6dfe4c1268baef74f62 100644
|
| --- a/net/base/sdch_manager_unittest.cc
|
| +++ b/net/base/sdch_manager_unittest.cc
|
| @@ -9,7 +9,9 @@
|
| #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 {
|
|
|
| @@ -21,14 +23,21 @@ static const char kTestVcdiffDictionary[] = "DictionaryFor"
|
|
|
| //------------------------------------------------------------------------------
|
|
|
| -class SdchManagerTest : public testing::Test {
|
| +class SdchManagerTest : public testing::Test,
|
| + public SdchObserver {
|
| protected:
|
| SdchManagerTest()
|
| : sdch_manager_(new SdchManager),
|
| default_support_(false),
|
| - default_https_support_(false) {
|
| + default_https_support_(false),
|
| + get_dictionary_notifications_(0) {
|
| default_support_ = sdch_manager_->sdch_enabled();
|
| default_https_support_ = sdch_manager_->secure_scheme_supported();
|
| + sdch_manager_->AddObserver(this);
|
| + }
|
| +
|
| + virtual ~SdchManagerTest() {
|
| + sdch_manager_->RemoveObserver(this);
|
| }
|
|
|
| SdchManager* sdch_manager() { return sdch_manager_.get(); }
|
| @@ -53,10 +62,28 @@ class SdchManagerTest : public testing::Test {
|
| return (list != list2);
|
| }
|
|
|
| + 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
|
| + virtual 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;
|
| + }
|
| +
|
| private:
|
| scoped_ptr<SdchManager> sdch_manager_;
|
| bool default_support_;
|
| bool default_https_support_;
|
| + int get_dictionary_notifications_;
|
| + GURL last_dictionary_request_url_;
|
| + GURL last_dictionary_url_;
|
| };
|
|
|
| //------------------------------------------------------------------------------
|
| @@ -560,4 +587,15 @@ TEST_F(SdchManagerTest, ClearDictionaryData) {
|
| EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_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"));
|
| +
|
| + EXPECT_EQ(0, get_dictionary_notifications());
|
| + sdch_manager()->OnGetDictionary(test_request_gurl, test_dictionary_gurl);
|
| + EXPECT_EQ(1, get_dictionary_notifications());
|
| + EXPECT_EQ(test_request_gurl, last_dictionary_request_url());
|
| + EXPECT_EQ(test_dictionary_gurl, last_dictionary_url());
|
| +}
|
| +
|
| } // namespace net
|
|
|