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

Unified Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc

Issue 137433010: Switch to EmbeddedTestServer to avoid flakiness. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use PathService for compatibility with test isolation Created 6 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
index 05c9d622c89d1ff139272551309955f01d878381..049afb358449272bf7541fa3e384a4de12389abe 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
@@ -12,7 +12,7 @@
#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_constants.h"
#include "content/public/browser/resource_request_info.h"
#include "net/base/request_priority.h"
-#include "net/test/spawned_test_server/spawned_test_server.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,14 +22,19 @@ using base::ListValue;
using base::StringValue;
using base::Value;
-namespace {
-const char kUnknownConditionName[] = "unknownType";
-} // namespace
-
namespace extensions {
namespace keys = declarative_webrequest_constants;
+namespace {
+const char kUnknownConditionName[] = "unknownType";
+
+base::FilePath TestDataPath(base::StringPiece relative_to_src) {
+ base::FilePath src_dir;
+ CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
+ return src_dir.AppendASCII(relative_to_src);
+}
+
TEST(WebRequestConditionAttributeTest, CreateConditionAttribute) {
// Necessary for TestURLRequest.
base::MessageLoopForIO message_loop;
@@ -111,16 +116,14 @@ TEST(WebRequestConditionAttributeTest, ContentType) {
std::string error;
scoped_refptr<const WebRequestConditionAttribute> result;
- net::SpawnedTestServer test_server(
- net::SpawnedTestServer::TYPE_HTTP,
- net::SpawnedTestServer::kLocalhost,
- base::FilePath(FILE_PATH_LITERAL(
- "chrome/test/data/extensions/api_test/webrequest/declarative")));
- ASSERT_TRUE(test_server.Start());
+ net::test_server::EmbeddedTestServer test_server;
+ test_server.ServeFilesFromDirectory(TestDataPath(
+ "chrome/test/data/extensions/api_test/webrequest/declarative"));
+ ASSERT_TRUE(test_server.InitializeAndWaitUntilReady());
net::TestURLRequestContext context;
net::TestDelegate delegate;
- net::TestURLRequest url_request(test_server.GetURL("files/headers.html"),
+ net::TestURLRequest url_request(test_server.GetURL("/headers.html"),
net::DEFAULT_PRIORITY,
&delegate,
&context);
@@ -500,16 +503,14 @@ TEST(WebRequestConditionAttributeTest, ResponseHeaders) {
// Necessary for TestURLRequest.
base::MessageLoopForIO message_loop;
- net::SpawnedTestServer test_server(
- net::SpawnedTestServer::TYPE_HTTP,
- net::SpawnedTestServer::kLocalhost,
- base::FilePath(FILE_PATH_LITERAL(
- "chrome/test/data/extensions/api_test/webrequest/declarative")));
- ASSERT_TRUE(test_server.Start());
+ net::test_server::EmbeddedTestServer test_server;
+ test_server.ServeFilesFromDirectory(TestDataPath(
+ "chrome/test/data/extensions/api_test/webrequest/declarative"));
+ ASSERT_TRUE(test_server.InitializeAndWaitUntilReady());
net::TestURLRequestContext context;
net::TestDelegate delegate;
- net::TestURLRequest url_request(test_server.GetURL("files/headers.html"),
+ net::TestURLRequest url_request(test_server.GetURL("/headers.html"),
net::DEFAULT_PRIORITY,
&delegate,
&context);
@@ -680,4 +681,5 @@ TEST(WebRequestConditionAttributeTest, ResponseHeaders) {
EXPECT_FALSE(result);
}
+} // namespace
vabr (Chromium) 2014/02/04 08:19:12 Did you put the whole test into anonymous namespac
Jeffrey Yasskin 2014/02/04 08:27:17 Yeah. It's nice to do that because it ensures that
} // namespace extensions
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698