| OLD | NEW |
| 1 // Copyright (C) 2013 Google Inc. | 1 // Copyright (C) 2013 Google Inc. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 Retriever bad_retriever(FakeDownloader::kFakeDataUrl, | 127 Retriever bad_retriever(FakeDownloader::kFakeDataUrl, |
| 128 scoped_ptr<Downloader>(new FaultyDownloader), | 128 scoped_ptr<Downloader>(new FaultyDownloader), |
| 129 scoped_ptr<Storage>(new FakeStorage)); | 129 scoped_ptr<Storage>(new FakeStorage)); |
| 130 bad_retriever.Retrieve(kKey, BuildCallback()); | 130 bad_retriever.Retrieve(kKey, BuildCallback()); |
| 131 | 131 |
| 132 EXPECT_FALSE(success_); | 132 EXPECT_FALSE(success_); |
| 133 EXPECT_EQ(kKey, key_); | 133 EXPECT_EQ(kKey, key_); |
| 134 EXPECT_TRUE(data_.empty()); | 134 EXPECT_TRUE(data_.empty()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 TEST_F(RetrieverTest, FaultyDownloaderFallback) { |
| 138 Retriever bad_retriever(FakeDownloader::kFakeDataUrl, |
| 139 scoped_ptr<Downloader>(new FaultyDownloader), |
| 140 scoped_ptr<Storage>(new FakeStorage)); |
| 141 const char kFallbackDataKey[] = "data/US"; |
| 142 bad_retriever.Retrieve(kFallbackDataKey, BuildCallback()); |
| 143 |
| 144 EXPECT_TRUE(success_); |
| 145 EXPECT_EQ(kFallbackDataKey, key_); |
| 146 EXPECT_FALSE(data_.empty()); |
| 147 EXPECT_NE(kEmptyData, data_); |
| 148 } |
| 149 |
| 137 // The downloader that doesn't get back to you. | 150 // The downloader that doesn't get back to you. |
| 138 class HangingDownloader : public Downloader { | 151 class HangingDownloader : public Downloader { |
| 139 public: | 152 public: |
| 140 HangingDownloader() {} | 153 HangingDownloader() {} |
| 141 virtual ~HangingDownloader() {} | 154 virtual ~HangingDownloader() {} |
| 142 | 155 |
| 143 // Downloader implementation. | 156 // Downloader implementation. |
| 144 virtual void Download(const std::string& url, | 157 virtual void Download(const std::string& url, |
| 145 scoped_ptr<Callback> downloaded) {} | 158 scoped_ptr<Callback> downloaded) {} |
| 146 }; | 159 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 171 EXPECT_EQ("", GetKeyForUrl("http://www.google.com/")); | 184 EXPECT_EQ("", GetKeyForUrl("http://www.google.com/")); |
| 172 EXPECT_EQ("", GetKeyForUrl("")); | 185 EXPECT_EQ("", GetKeyForUrl("")); |
| 173 EXPECT_EQ("", GetKeyForUrl("test:///")); | 186 EXPECT_EQ("", GetKeyForUrl("test:///")); |
| 174 EXPECT_EQ("data", GetKeyForUrl("test:///data")); | 187 EXPECT_EQ("data", GetKeyForUrl("test:///data")); |
| 175 EXPECT_EQ("data/US", GetKeyForUrl("test:///data/US")); | 188 EXPECT_EQ("data/US", GetKeyForUrl("test:///data/US")); |
| 176 EXPECT_EQ("data/CA--fr", GetKeyForUrl("test:///data/CA--fr")); | 189 EXPECT_EQ("data/CA--fr", GetKeyForUrl("test:///data/CA--fr")); |
| 177 } | 190 } |
| 178 | 191 |
| 179 } // namespace addressinput | 192 } // namespace addressinput |
| 180 } // namespace i18n | 193 } // namespace i18n |
| OLD | NEW |