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

Unified Diff: net/proxy/network_delegate_error_observer_unittest.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | « net/proxy/network_delegate_error_observer.cc ('k') | net/proxy/polling_proxy_config_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/network_delegate_error_observer_unittest.cc
diff --git a/net/proxy/network_delegate_error_observer_unittest.cc b/net/proxy/network_delegate_error_observer_unittest.cc
deleted file mode 100644
index 0a2e01ace646ce4bf676b932db6fa877fface17f..0000000000000000000000000000000000000000
--- a/net/proxy/network_delegate_error_observer_unittest.cc
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/proxy/network_delegate_error_observer.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/threading/thread.h"
-#include "net/base/net_errors.h"
-#include "net/base/network_delegate_impl.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace net {
-
-namespace {
-
-class TestNetworkDelegate : public net::NetworkDelegateImpl {
- public:
- TestNetworkDelegate() : got_pac_error_(false) {}
- ~TestNetworkDelegate() override {}
-
- bool got_pac_error() const { return got_pac_error_; }
-
- private:
- // net::NetworkDelegate implementation.
- int OnBeforeURLRequest(URLRequest* request,
- const CompletionCallback& callback,
- GURL* new_url) override {
- return OK;
- }
- int OnBeforeSendHeaders(URLRequest* request,
- const CompletionCallback& callback,
- HttpRequestHeaders* headers) override {
- return OK;
- }
- void OnSendHeaders(URLRequest* request,
- const HttpRequestHeaders& headers) override {}
- int OnHeadersReceived(
- URLRequest* request,
- const CompletionCallback& callback,
- const HttpResponseHeaders* original_response_headers,
- scoped_refptr<HttpResponseHeaders>* override_response_headers,
- GURL* allowed_unsafe_redirect_url) override {
- return net::OK;
- }
- void OnBeforeRedirect(URLRequest* request,
- const GURL& new_location) override {}
- void OnResponseStarted(URLRequest* request) override {}
- void OnRawBytesRead(const URLRequest& request, int bytes_read) override {}
- void OnCompleted(URLRequest* request, bool started) override {}
- void OnURLRequestDestroyed(URLRequest* request) override {}
-
- void OnPACScriptError(int line_number, const base::string16& error) override {
- got_pac_error_ = true;
- }
- AuthRequiredResponse OnAuthRequired(URLRequest* request,
- const AuthChallengeInfo& auth_info,
- const AuthCallback& callback,
- AuthCredentials* credentials) override {
- return AUTH_REQUIRED_RESPONSE_NO_ACTION;
- }
- bool OnCanGetCookies(const URLRequest& request,
- const CookieList& cookie_list) override {
- return true;
- }
- bool OnCanSetCookie(const URLRequest& request,
- const std::string& cookie_line,
- CookieOptions* options) override {
- return true;
- }
- bool OnCanAccessFile(const net::URLRequest& request,
- const base::FilePath& path) const override {
- return true;
- }
- bool OnCanThrottleRequest(const URLRequest& request) const override {
- return false;
- }
-
- bool got_pac_error_;
-};
-
-} // namespace
-
-// Check that the OnPACScriptError method can be called from an arbitrary
-// thread.
-TEST(NetworkDelegateErrorObserverTest, CallOnThread) {
- base::Thread thread("test_thread");
- thread.Start();
- TestNetworkDelegate network_delegate;
- NetworkDelegateErrorObserver observer(
- &network_delegate, base::MessageLoopProxy::current().get());
- thread.message_loop()
- ->PostTask(FROM_HERE,
- base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError,
- base::Unretained(&observer),
- 42,
- base::string16()));
- thread.Stop();
- base::MessageLoop::current()->RunUntilIdle();
- ASSERT_TRUE(network_delegate.got_pac_error());
-}
-
-// Check that passing a NULL network delegate works.
-TEST(NetworkDelegateErrorObserverTest, NoDelegate) {
- base::Thread thread("test_thread");
- thread.Start();
- NetworkDelegateErrorObserver observer(
- NULL, base::MessageLoopProxy::current().get());
- thread.message_loop()
- ->PostTask(FROM_HERE,
- base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError,
- base::Unretained(&observer),
- 42,
- base::string16()));
- thread.Stop();
- base::MessageLoop::current()->RunUntilIdle();
- // Shouldn't have crashed until here...
-}
-
-} // namespace net
« no previous file with comments | « net/proxy/network_delegate_error_observer.cc ('k') | net/proxy/polling_proxy_config_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698