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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CAPTIVE_PORTAL_TESTING_UTILS_H_
6 #define CHROME_BROWSER_CAPTIVE_PORTAL_TESTING_UTILS_H_
10 #include "base/basictypes.h"
11 #include "chrome/browser/captive_portal/captive_portal_detector.h"
12 #include "net/url_request/test_url_fetcher_factory.h"
22 namespace captive_portal
{
24 class CaptivePortalDetectorTestBase
{
26 CaptivePortalDetectorTestBase();
27 virtual ~CaptivePortalDetectorTestBase();
29 // Sets test time for captive portal detector.
30 void SetTime(const base::Time
& time
);
32 // Advances test time for captive portal detector.
33 void AdvanceTime(const base::TimeDelta
& time_delta
);
37 // Sets URL fetcher state and notifies portal detector.
38 void CompleteURLFetch(int net_error
,
40 const char* response_headers
);
42 void set_detector(CaptivePortalDetector
* detector
) { detector_
= detector
; }
44 CaptivePortalDetector
* detector() { return detector_
; }
46 net::TestURLFetcher
* fetcher() { return factory_
.GetFetcherByID(0); }
49 CaptivePortalDetector
* detector_
;
51 net::TestURLFetcherFactory factory_
;
53 DISALLOW_COPY_AND_ASSIGN(CaptivePortalDetectorTestBase
);
56 } // namespace captive_portal
58 #endif // CHROME_BROWSER_CAPTIVE_PORTAL_TESTING_UTILS_H_