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

Side by Side Diff: chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 30 matching lines...) Expand all
41 41
42 void AssertIntercepted( 42 void AssertIntercepted(
43 const GURL& url, 43 const GURL& url,
44 net::URLRequestJobFactory::Interceptor* interceptor) { 44 net::URLRequestJobFactory::Interceptor* interceptor) {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
46 BrowserThread::PostTask(BrowserThread::IO, 46 BrowserThread::PostTask(BrowserThread::IO,
47 FROM_HERE, 47 FROM_HERE,
48 base::Bind(AssertInterceptedIO, 48 base::Bind(AssertInterceptedIO,
49 url, 49 url,
50 base::Unretained(interceptor))); 50 base::Unretained(interceptor)));
51 MessageLoop::current()->RunAllPending(); 51 MessageLoop::current()->RunUntilIdle();
52 } 52 }
53 53
54 void AssertWillHandleIO( 54 void AssertWillHandleIO(
55 const std::string& scheme, 55 const std::string& scheme,
56 bool expected, 56 bool expected,
57 net::URLRequestJobFactory::Interceptor* interceptor) { 57 net::URLRequestJobFactory::Interceptor* interceptor) {
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
59 ASSERT_EQ(expected, interceptor->WillHandleProtocol(scheme)); 59 ASSERT_EQ(expected, interceptor->WillHandleProtocol(scheme));
60 } 60 }
61 61
62 void AssertWillHandle( 62 void AssertWillHandle(
63 const std::string& scheme, 63 const std::string& scheme,
64 bool expected, 64 bool expected,
65 net::URLRequestJobFactory::Interceptor* interceptor) { 65 net::URLRequestJobFactory::Interceptor* interceptor) {
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
67 BrowserThread::PostTask(BrowserThread::IO, 67 BrowserThread::PostTask(BrowserThread::IO,
68 FROM_HERE, 68 FROM_HERE,
69 base::Bind(AssertWillHandleIO, 69 base::Bind(AssertWillHandleIO,
70 scheme, 70 scheme,
71 expected, 71 expected,
72 base::Unretained(interceptor))); 72 base::Unretained(interceptor)));
73 MessageLoop::current()->RunAllPending(); 73 MessageLoop::current()->RunUntilIdle();
74 } 74 }
75 75
76 class FakeDelegate : public ProtocolHandlerRegistry::Delegate { 76 class FakeDelegate : public ProtocolHandlerRegistry::Delegate {
77 public: 77 public:
78 FakeDelegate() : force_os_failure_(false) {} 78 FakeDelegate() : force_os_failure_(false) {}
79 virtual ~FakeDelegate() { } 79 virtual ~FakeDelegate() { }
80 virtual void RegisterExternalHandler(const std::string& protocol) { 80 virtual void RegisterExternalHandler(const std::string& protocol) {
81 ASSERT_TRUE( 81 ASSERT_TRUE(
82 registered_protocols_.find(protocol) == registered_protocols_.end()); 82 registered_protocols_.find(protocol) == registered_protocols_.end());
83 registered_protocols_.insert(protocol); 83 registered_protocols_.insert(protocol);
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 886
887 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { 887 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) {
888 RecreateRegistry(false); 888 RecreateRegistry(false);
889 registry()->AddPredefinedHandler(CreateProtocolHandler( 889 registry()->AddPredefinedHandler(CreateProtocolHandler(
890 "test", GURL("http://test.com/%s"), "Test")); 890 "test", GURL("http://test.com/%s"), "Test"));
891 registry()->InitProtocolSettings(); 891 registry()->InitProtocolSettings();
892 std::vector<std::string> protocols; 892 std::vector<std::string> protocols;
893 registry()->GetRegisteredProtocols(&protocols); 893 registry()->GetRegisteredProtocols(&protocols);
894 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); 894 ASSERT_EQ(static_cast<size_t>(1), protocols.size());
895 } 895 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698