| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/variations/service/ui_string_overrider.h" |
| 6 |
| 5 #include "chrome/browser/metrics/variations/generated_resources_map.h" | 7 #include "chrome/browser/metrics/variations/generated_resources_map.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 9 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 10 // TODO(sdefresne): componentize this tests as part of the resolution |
| 11 // of http://crbug.com/534257 ("Decouple iOS port from using //chrome's |
| 12 // VariationsService client"). |
| 8 | 13 |
| 9 namespace chrome_variations { | 14 namespace chrome_variations { |
| 10 | 15 |
| 11 TEST(GeneratedResourcesMapLookupTest, LookupNotFound) { | 16 class UIStringOverriderTest : public ::testing::Test { |
| 17 public: |
| 18 UIStringOverriderTest() |
| 19 : provider_(kResourceHashes, kResourceIndices, kNumResources) {} |
| 20 |
| 21 int GetResourceIndex(uint32_t hash) { |
| 22 return provider_.GetResourceIndex(hash); |
| 23 } |
| 24 |
| 25 private: |
| 26 variations::UIStringOverrider provider_; |
| 27 |
| 28 DISALLOW_COPY_AND_ASSIGN(UIStringOverriderTest); |
| 29 }; |
| 30 |
| 31 TEST_F(UIStringOverriderTest, LookupNotFound) { |
| 12 EXPECT_EQ(-1, GetResourceIndex(0)); | 32 EXPECT_EQ(-1, GetResourceIndex(0)); |
| 13 EXPECT_EQ(-1, GetResourceIndex(kResourceHashes[kNumResources - 1] + 1)); | 33 EXPECT_EQ(-1, GetResourceIndex(kResourceHashes[kNumResources - 1] + 1)); |
| 14 | 34 |
| 15 // Lookup a hash that shouldn't exist. | 35 // Lookup a hash that shouldn't exist. |
| 16 // 13257681U is 1 + the hash for IDS_ZOOM_NORMAL | 36 // 13257681U is 1 + the hash for IDS_ZOOM_NORMAL |
| 17 EXPECT_EQ(-1, GetResourceIndex(13257681U)); | 37 EXPECT_EQ(-1, GetResourceIndex(13257681U)); |
| 18 } | 38 } |
| 19 | 39 |
| 20 TEST(GeneratedResourcesMapLookupTest, LookupFound) { | 40 TEST_F(UIStringOverriderTest, LookupFound) { |
| 21 for (size_t i = 0; i < kNumResources; ++i) | 41 for (size_t i = 0; i < kNumResources; ++i) |
| 22 EXPECT_EQ(kResourceIndices[i], GetResourceIndex(kResourceHashes[i])); | 42 EXPECT_EQ(kResourceIndices[i], GetResourceIndex(kResourceHashes[i])); |
| 23 } | 43 } |
| 24 | 44 |
| 25 } // namespace chrome_variations | 45 } // namespace chrome_variations |
| OLD | NEW |