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

Unified Diff: net/http/http_server_properties_manager_unittest.cc

Issue 378823002: Move http_server_properties_manager from chrome/browser/net to net/http. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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: net/http/http_server_properties_manager_unittest.cc
diff --git a/chrome/browser/net/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc
similarity index 89%
rename from chrome/browser/net/http_server_properties_manager_unittest.cc
rename to net/http/http_server_properties_manager_unittest.cc
index fdaee6c1d48d4c0c4324a446efdb3efdb65cf50c..b60161758314bd37340fe30310aa816236448b84 100644
--- a/chrome/browser/net/http_server_properties_manager_unittest.cc
+++ b/net/http/http_server_properties_manager_unittest.cc
@@ -2,20 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/net/http_server_properties_manager.h"
+#include "net/http/http_server_properties_manager.h"
#include "base/basictypes.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/testing_pref_service.h"
+#include "base/test/test_simple_task_runner.h"
#include "base/values.h"
-#include "chrome/common/pref_names.h"
-#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
-namespace chrome_browser_net {
+namespace net {
namespace {
@@ -23,12 +22,18 @@ using ::testing::_;
using ::testing::Invoke;
using ::testing::Mock;
using ::testing::StrictMock;
-using content::BrowserThread;
+
+const char kTestHttpServerProperties[] = "TestHttpServerProperties";
class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager {
public:
- explicit TestingHttpServerPropertiesManager(PrefService* pref_service)
- : HttpServerPropertiesManager(pref_service) {
+ TestingHttpServerPropertiesManager(
+ PrefService* pref_service,
+ const char* path,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
+ : HttpServerPropertiesManager(
+ pref_service, path, ui_task_runner, io_task_runner) {
InitializeOnIOThread();
}
@@ -78,26 +83,25 @@ class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager {
class HttpServerPropertiesManagerTest : public testing::Test {
protected:
- HttpServerPropertiesManagerTest()
- : ui_thread_(BrowserThread::UI, &loop_),
- io_thread_(BrowserThread::IO, &loop_) {
- }
+ HttpServerPropertiesManagerTest() {}
virtual void SetUp() OVERRIDE {
pref_service_.registry()->RegisterDictionaryPref(
- prefs::kHttpServerProperties);
+ kTestHttpServerProperties);
http_server_props_manager_.reset(
- new StrictMock<TestingHttpServerPropertiesManager>(&pref_service_));
+ new StrictMock<TestingHttpServerPropertiesManager>(
+ &pref_service_,
+ kTestHttpServerProperties,
+ base::MessageLoop::current()->message_loop_proxy(),
+ base::MessageLoop::current()->message_loop_proxy()));
ExpectCacheUpdate();
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
virtual void TearDown() OVERRIDE {
if (http_server_props_manager_.get())
http_server_props_manager_->ShutdownOnUIThread();
- loop_.RunUntilIdle();
- // Delete |http_server_props_manager_| while |io_thread_| is mapping IO to
- // |loop_|.
+ base::MessageLoop::current()->RunUntilIdle();
http_server_props_manager_.reset();
}
@@ -125,14 +129,10 @@ class HttpServerPropertiesManagerTest : public testing::Test {
UpdatePrefsFromCacheOnIOConcrete));
}
- base::MessageLoop loop_;
TestingPrefServiceSimple pref_service_;
scoped_ptr<TestingHttpServerPropertiesManager> http_server_props_manager_;
private:
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread io_thread_;
-
DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest);
};
@@ -184,14 +184,14 @@ TEST_F(HttpServerPropertiesManagerTest,
http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict);
// Set the same value for kHttpServerProperties multiple times.
- pref_service_.SetManagedPref(prefs::kHttpServerProperties,
+ pref_service_.SetManagedPref(kTestHttpServerProperties,
http_server_properties_dict);
base::DictionaryValue* http_server_properties_dict2 =
http_server_properties_dict->DeepCopy();
- pref_service_.SetManagedPref(prefs::kHttpServerProperties,
+ pref_service_.SetManagedPref(kTestHttpServerProperties,
http_server_properties_dict2);
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
// Verify SupportsSpdy.
@@ -231,7 +231,7 @@ TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) {
http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
// Run the task.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail));
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
@@ -249,7 +249,7 @@ TEST_F(HttpServerPropertiesManagerTest, SetSpdySetting) {
spdy_server_mail, id1, flags1, value1);
// Run the task.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
const net::SettingsMap& settings_map1_ret =
http_server_props_manager_->GetSpdySettings(spdy_server_mail);
@@ -275,7 +275,7 @@ TEST_F(HttpServerPropertiesManagerTest, ClearSpdySetting) {
spdy_server_mail, id1, flags1, value1);
// Run the task.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
const net::SettingsMap& settings_map1_ret =
http_server_props_manager_->GetSpdySettings(spdy_server_mail);
@@ -290,7 +290,7 @@ TEST_F(HttpServerPropertiesManagerTest, ClearSpdySetting) {
http_server_props_manager_->ClearSpdySettings(spdy_server_mail);
// Run the task.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
// Verify that there are no entries in the settings map for
// mail.google.com:443.
@@ -313,7 +313,7 @@ TEST_F(HttpServerPropertiesManagerTest, ClearAllSpdySetting) {
spdy_server_mail, id1, flags1, value1);
// Run the task.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
const net::SettingsMap& settings_map1_ret =
http_server_props_manager_->GetSpdySettings(spdy_server_mail);
@@ -328,7 +328,7 @@ TEST_F(HttpServerPropertiesManagerTest, ClearAllSpdySetting) {
http_server_props_manager_->ClearAllSpdySettings();
// Run the task.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
// Verify that there are no entries in the settings map.
const net::SpdySettingsMap& spdy_settings_map2_ret =
@@ -348,7 +348,7 @@ TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) {
spdy_server_mail, 443, net::NPN_SPDY_3);
// Run the task.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
ASSERT_TRUE(
@@ -374,7 +374,7 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) {
spdy_server_mail, id1, flags1, value1);
// Run the task.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(spdy_server_mail));
EXPECT_TRUE(
@@ -396,7 +396,7 @@ TEST_F(HttpServerPropertiesManagerTest, Clear) {
// Clear http server data, time out if we do not get a completion callback.
http_server_props_manager_->Clear(base::MessageLoop::QuitClosure());
- loop_.Run();
+ base::MessageLoop::current()->Run();
EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(spdy_server_mail));
EXPECT_FALSE(
@@ -416,7 +416,7 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache0) {
http_server_props_manager_->ShutdownOnUIThread();
http_server_props_manager_.reset();
// Run the task after shutdown and deletion.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) {
@@ -425,10 +425,10 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache1) {
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
// Run the task after shutdown, but before deletion.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
http_server_props_manager_.reset();
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) {
@@ -436,10 +436,10 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdateCache2) {
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
// Run the task after shutdown, but before deletion.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
http_server_props_manager_.reset();
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
//
@@ -452,7 +452,7 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) {
http_server_props_manager_->ShutdownOnUIThread();
http_server_props_manager_.reset();
// Run the task after shutdown and deletion.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) {
@@ -462,10 +462,10 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) {
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
// Run the task after shutdown, but before deletion.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
http_server_props_manager_.reset();
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) {
@@ -474,10 +474,10 @@ TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) {
// Shutdown comes before the task is executed.
http_server_props_manager_->ShutdownOnUIThread();
// Run the task after shutdown, but before deletion.
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
http_server_props_manager_.reset();
- loop_.RunUntilIdle();
+ base::MessageLoop::current()->RunUntilIdle();
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698