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 COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TESTING_UTILS_H_
6 #define COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TESTING_UTILS_H_
10 #include "base/basictypes.h"
11 #include "components/captive_portal/captive_portal_detector.h"
12 #include "net/url_request/test_url_fetcher_factory.h"
18 namespace captive_portal
{
20 class CaptivePortalDetectorTestBase
{
22 CaptivePortalDetectorTestBase();
23 virtual ~CaptivePortalDetectorTestBase();
25 // Sets test time for captive portal detector.
26 void SetTime(const base::Time
& time
);
28 // Advances test time for captive portal detector.
29 void AdvanceTime(const base::TimeDelta
& time_delta
);
33 // Sets URL fetcher state and notifies portal detector.
34 void CompleteURLFetch(int net_error
,
36 const char* response_headers
);
38 void set_detector(CaptivePortalDetector
* detector
) { detector_
= detector
; }
40 CaptivePortalDetector
* detector() { return detector_
; }
42 net::TestURLFetcher
* fetcher() { return factory_
.GetFetcherByID(0); }
45 CaptivePortalDetector
* detector_
;
47 net::TestURLFetcherFactory factory_
;
49 DISALLOW_COPY_AND_ASSIGN(CaptivePortalDetectorTestBase
);
52 } // namespace captive_portal
54 #endif // COMPONENTS_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TESTING_UTILS_H_