Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: components/variations/service/ui_string_overrider_unittest.cc

Issue 1374773002: Componentize script to generate UI string overrides mapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get-resources-index
Patch Set: Rebase and fix //components/variations:unit_tests build with gn 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
« no previous file with comments | « components/variations/service/ui_string_overrider.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 5 #include "components/variations/service/ui_string_overrider.h"
6 6
7 #include "chrome/browser/metrics/variations/generated_resources_map.h"
8 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
9 8
10 // TODO(sdefresne): componentize this tests as part of the resolution 9 namespace chrome_variations {
11 // of http://crbug.com/534257 ("Decouple iOS port from using //chrome's
12 // VariationsService client").
13 10
14 namespace chrome_variations { 11 namespace {
12
13 const size_t kNumResources = 4;
14
15 const uint32_t kResourceHashes[] = {
16 301430091U, // IDS_BOOKMARKS_NO_ITEMS
17 2654138887U, // IDS_BOOKMARK_BAR_IMPORT_LINK
18 2894469061U, // IDS_BOOKMARK_GROUP_FROM_IE
19 3847176170U, // IDS_BOOKMARK_GROUP_FROM_FIREFOX
20 };
21
22 const int kResourceIndices[] = {
23 12500, // IDS_BOOKMARKS_NO_ITEMS
24 12501, // IDS_BOOKMARK_BAR_IMPORT_LINK
25 12502, // IDS_BOOKMARK_GROUP_FROM_IE
26 12503, // IDS_BOOKMARK_GROUP_FROM_FIREFOX
27 };
28
29 } // namespace
15 30
16 class UIStringOverriderTest : public ::testing::Test { 31 class UIStringOverriderTest : public ::testing::Test {
17 public: 32 public:
18 UIStringOverriderTest() 33 UIStringOverriderTest()
19 : provider_(kResourceHashes, kResourceIndices, kNumResources) {} 34 : provider_(kResourceHashes, kResourceIndices, kNumResources) {}
20 35
21 int GetResourceIndex(uint32_t hash) { 36 int GetResourceIndex(uint32_t hash) {
22 return provider_.GetResourceIndex(hash); 37 return provider_.GetResourceIndex(hash);
23 } 38 }
24 39
25 private: 40 private:
26 variations::UIStringOverrider provider_; 41 variations::UIStringOverrider provider_;
27 42
28 DISALLOW_COPY_AND_ASSIGN(UIStringOverriderTest); 43 DISALLOW_COPY_AND_ASSIGN(UIStringOverriderTest);
29 }; 44 };
30 45
31 TEST_F(UIStringOverriderTest, LookupNotFound) { 46 TEST_F(UIStringOverriderTest, LookupNotFound) {
32 EXPECT_EQ(-1, GetResourceIndex(0)); 47 EXPECT_EQ(-1, GetResourceIndex(0));
33 EXPECT_EQ(-1, GetResourceIndex(kResourceHashes[kNumResources - 1] + 1)); 48 EXPECT_EQ(-1, GetResourceIndex(kResourceHashes[kNumResources - 1] + 1));
34 49
35 // Lookup a hash that shouldn't exist. 50 // Lookup a hash that shouldn't exist.
36 // 13257681U is 1 + the hash for IDS_ZOOM_NORMAL 51 // 3847176171U is 1 + the hash for IDS_BOOKMARK_GROUP_FROM_FIREFOX.
37 EXPECT_EQ(-1, GetResourceIndex(13257681U)); 52 EXPECT_EQ(-1, GetResourceIndex(3847176171U));
38 } 53 }
39 54
40 TEST_F(UIStringOverriderTest, LookupFound) { 55 TEST_F(UIStringOverriderTest, LookupFound) {
41 for (size_t i = 0; i < kNumResources; ++i) 56 for (size_t i = 0; i < kNumResources; ++i)
42 EXPECT_EQ(kResourceIndices[i], GetResourceIndex(kResourceHashes[i])); 57 EXPECT_EQ(kResourceIndices[i], GetResourceIndex(kResourceHashes[i]));
43 } 58 }
44 59
45 } // namespace chrome_variations 60 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « components/variations/service/ui_string_overrider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698