Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/browser/metrics/variations/ui_string_overrider_unittest.cc

Issue 1363243004: Allow embedders to share code to override UI strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments by asvitkine Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
6
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 9
9 namespace chrome_variations { 10 namespace chrome_variations {
10 11
11 TEST(GeneratedResourcesMapLookupTest, LookupNotFound) { 12 class UIStringOverriderTest : public ::testing::Test {
Alexei Svitkine (slow) 2015/09/28 15:01:46 Nit: Please add a TODO to componentize this test.
sdefresne 2015/09/28 16:53:55 Done.
13 public:
14 UIStringOverriderTest()
15 : provider_(kResourceHashes, kResourceIndices, kNumResources) {}
16
17 int GetResourceIndex(uint32_t hash) {
18 return provider_.GetResourceIndex(hash);
19 }
20
21 private:
22 variations::UIStringOverrider provider_;
23
24 DISALLOW_COPY_AND_ASSIGN(UIStringOverriderTest);
25 };
26
27 TEST_F(UIStringOverriderTest, LookupNotFound) {
12 EXPECT_EQ(-1, GetResourceIndex(0)); 28 EXPECT_EQ(-1, GetResourceIndex(0));
13 EXPECT_EQ(-1, GetResourceIndex(kResourceHashes[kNumResources - 1] + 1)); 29 EXPECT_EQ(-1, GetResourceIndex(kResourceHashes[kNumResources - 1] + 1));
14 30
15 // Lookup a hash that shouldn't exist. 31 // Lookup a hash that shouldn't exist.
16 // 13257681U is 1 + the hash for IDS_ZOOM_NORMAL 32 // 13257681U is 1 + the hash for IDS_ZOOM_NORMAL
17 EXPECT_EQ(-1, GetResourceIndex(13257681U)); 33 EXPECT_EQ(-1, GetResourceIndex(13257681U));
18 } 34 }
19 35
20 TEST(GeneratedResourcesMapLookupTest, LookupFound) { 36 TEST_F(UIStringOverriderTest, LookupFound) {
21 for (size_t i = 0; i < kNumResources; ++i) 37 for (size_t i = 0; i < kNumResources; ++i)
22 EXPECT_EQ(kResourceIndices[i], GetResourceIndex(kResourceHashes[i])); 38 EXPECT_EQ(kResourceIndices[i], GetResourceIndex(kResourceHashes[i]));
23 } 39 }
24 40
25 } // namespace chrome_variations 41 } // namespace chrome_variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698