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

Side by Side Diff: chrome/browser/policy/device_management_service_unittest.cc

Issue 7524033: Add a scoper object for URLFetcher::Factory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_split.h" 8 #include "base/string_split.h"
9 #include "chrome/browser/policy/device_management_backend_impl.h" 9 #include "chrome/browser/policy/device_management_backend_impl.h"
10 #include "chrome/browser/policy/device_management_backend_mock.h" 10 #include "chrome/browser/policy/device_management_backend_mock.h"
11 #include "chrome/browser/policy/device_management_service.h" 11 #include "chrome/browser/policy/device_management_service.h"
12 #include "chrome/browser/policy/proto/device_management_constants.h" 12 #include "chrome/browser/policy/proto/device_management_constants.h"
13 #include "content/browser/browser_thread.h" 13 #include "content/browser/browser_thread.h"
14 #include "content/common/test_url_fetcher_factory.h" 14 #include "content/test/test_url_fetcher_factory.h"
15 #include "net/base/escape.h" 15 #include "net/base/escape.h"
16 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
17 #include "net/url_request/url_request_test_util.h" 17 #include "net/url_request/url_request_test_util.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using testing::IgnoreResult; 21 using testing::IgnoreResult;
22 using testing::InvokeWithoutArgs; 22 using testing::InvokeWithoutArgs;
23 using testing::_; 23 using testing::_;
24 24
(...skipping 18 matching lines...) Expand all
43 template<typename TESTBASE> 43 template<typename TESTBASE>
44 class DeviceManagementServiceTestBase : public TESTBASE { 44 class DeviceManagementServiceTestBase : public TESTBASE {
45 protected: 45 protected:
46 DeviceManagementServiceTestBase() 46 DeviceManagementServiceTestBase()
47 : ui_thread_(BrowserThread::UI, &loop_), 47 : ui_thread_(BrowserThread::UI, &loop_),
48 io_thread_(BrowserThread::IO, &loop_) { 48 io_thread_(BrowserThread::IO, &loop_) {
49 ResetService(); 49 ResetService();
50 InitializeService(); 50 InitializeService();
51 } 51 }
52 52
53 virtual void SetUp() {
54 URLFetcher::set_factory(&factory_);
55 }
56
57 virtual void TearDown() { 53 virtual void TearDown() {
58 URLFetcher::set_factory(NULL);
59 backend_.reset(); 54 backend_.reset();
60 service_.reset(); 55 service_.reset();
61 loop_.RunAllPending(); 56 loop_.RunAllPending();
57 TESTBASE::TearDown();
62 } 58 }
63 59
64 void ResetService() { 60 void ResetService() {
65 backend_.reset(); 61 backend_.reset();
66 service_.reset(new DeviceManagementService(kServiceUrl)); 62 service_.reset(new DeviceManagementService(kServiceUrl));
67 backend_.reset(service_->CreateBackend()); 63 backend_.reset(service_->CreateBackend());
68 } 64 }
69 65
70 void InitializeService() { 66 void InitializeService() {
71 service_->ScheduleInitialization(0); 67 service_->ScheduleInitialization(0);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 status, 491 status,
496 500, 492 500,
497 net::ResponseCookies(), 493 net::ResponseCookies(),
498 ""); 494 "");
499 495
500 // Backend should have been reset. 496 // Backend should have been reset.
501 EXPECT_FALSE(backend_.get()); 497 EXPECT_FALSE(backend_.get());
502 } 498 }
503 499
504 } // namespace policy 500 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698