OLD | NEW |
| (Empty) |
1 // Copyright (C) 2013 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // | |
15 // A fake downloader object to use in tests. Reads data from a file instead of | |
16 // downloading it from a server. | |
17 | |
18 #ifndef I18N_ADDRESSINPUT_TEST_FAKE_DOWNLOADER_H_ | |
19 #define I18N_ADDRESSINPUT_TEST_FAKE_DOWNLOADER_H_ | |
20 | |
21 #include <libaddressinput/downloader.h> | |
22 | |
23 #include <string> | |
24 | |
25 namespace i18n { | |
26 namespace addressinput { | |
27 | |
28 // "Downloads" serialized validation rules from a test data file. Sample usage: | |
29 // class MyClass { | |
30 // public: | |
31 // MyClass() {} | |
32 // | |
33 // ~MyClass() {} | |
34 // | |
35 // void GetData(const std::string& key) { | |
36 // downloader_.Download(std::string(FakeDownloader::kFakeDataUrl) + key, | |
37 // BuildCallback(this, &MyClass::OnDownloaded)); | |
38 // } | |
39 // | |
40 // private: | |
41 // void OnDownloaded(bool success, | |
42 // const std::string& url, | |
43 // const std::string& data) { | |
44 // ... | |
45 // } | |
46 // | |
47 // FakeDownloader downloader_; | |
48 // | |
49 // DISALLOW_COPY_AND_ASSIGN(MyClass); | |
50 // }; | |
51 class FakeDownloader : public Downloader { | |
52 public: | |
53 // The fake data URL to be used in tests. | |
54 static const char kFakeDataUrl[]; | |
55 | |
56 FakeDownloader(); | |
57 virtual ~FakeDownloader(); | |
58 | |
59 // Downloader implementation. | |
60 virtual void Download(const std::string& url, | |
61 scoped_ptr<Callback> downloaded); | |
62 }; | |
63 | |
64 } // namespace addressinput | |
65 } // namespace i18n | |
66 | |
67 #endif // I18N_ADDRESSINPUT_TEST_FAKE_DOWNLOADER_H_ | |
OLD | NEW |