Make |context| passed to queryRequiredElement optional
[chromium-blink-merge.git] / components / captive_portal / captive_portal_testing_utils.h
blobb0a59957cc5469c87a4ed76ee960ed283da9cafc
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "components/captive_portal/captive_portal_detector.h"
12 #include "net/url_request/test_url_fetcher_factory.h"
14 namespace base {
15 class Time;
18 namespace captive_portal {
20 class CaptivePortalDetectorTestBase {
21 public:
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);
31 bool FetchingURL();
33 // Sets URL fetcher state and notifies portal detector.
34 void CompleteURLFetch(int net_error,
35 int status_code,
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); }
44 protected:
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_