OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/resources_util.h" | 5 #include "chrome/browser/resources_util.h" |
6 | 6 |
7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
8 #include "grit/ui_resources.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace { | |
11 | |
12 struct TestCase { | |
13 const char* name; | |
14 int id; | |
15 }; | |
16 | |
17 } // namespace | |
18 | |
19 TEST(ResourcesUtil, SpotCheckIds) { | 11 TEST(ResourcesUtil, SpotCheckIds) { |
20 const TestCase kTestCases[] = { | 12 const struct { |
13 const char* name; | |
14 int id; | |
15 } cases[] = { | |
oshima
2013/01/08 22:36:34
shouldn't this still be kTestCases as it's still c
msw
2013/01/08 23:07:37
Done. For some reason, I thought I had seen the op
oshima
2013/01/08 23:10:27
If that's recommended style, then I'm fine. I just
| |
16 // IDRs from chrome/app/theme/theme_resources.grd should be valid. | |
21 {"IDR_BACK", IDR_BACK}, | 17 {"IDR_BACK", IDR_BACK}, |
22 {"IDR_STOP", IDR_STOP}, | 18 {"IDR_STOP", IDR_STOP}, |
23 {"IDR_OMNIBOX_STAR", IDR_OMNIBOX_STAR}, | 19 // IDRs from ui/resources/ui_resources.grd should be valid. |
24 {"IDR_SAD_TAB", IDR_SAD_TAB}, | 20 {"IDR_CHECKMARK", IDR_CHECKMARK}, |
21 {"IDR_THROBBER", IDR_THROBBER}, | |
22 // Unknown names should be invalid and return -1. | |
23 {"foobar", -1}, | |
24 {"backstar", -1}, | |
25 }; | 25 }; |
26 for (size_t i = 0; i < arraysize(kTestCases); ++i) { | |
27 EXPECT_EQ(kTestCases[i].id, | |
28 ResourcesUtil::GetThemeResourceId(kTestCases[i].name)); | |
29 } | |
30 | 26 |
31 // Should return -1 of unknown names. | 27 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) |
32 EXPECT_EQ(-1, ResourcesUtil::GetThemeResourceId("foobar")); | 28 EXPECT_EQ(cases[i].id, ResourcesUtil::GetThemeResourceId(cases[i].name)); |
33 EXPECT_EQ(-1, ResourcesUtil::GetThemeResourceId("backstar")); | |
34 } | 29 } |
OLD | NEW |