OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/basictypes.h" | |
6 #include "chrome/browser/ui/intents/web_intent_picker.h" | |
7 #include "grit/theme_resources.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 | |
10 class WebIntentPickerTest : public testing::Test { | |
11 public: | |
12 WebIntentPickerTest() {} | |
13 }; | |
14 | |
15 TEST_F(WebIntentPickerTest, GetStarImageIdsFromCWSRating) { | |
16 struct TestCase { | |
17 double rating; | |
18 int index; | |
19 int expected_star_image; | |
20 } test_cases[] = { | |
21 { 3.4, 0, IDR_CWS_STAR_FULL }, | |
22 { 3.4, 1, IDR_CWS_STAR_FULL }, | |
23 { 3.4, 2, IDR_CWS_STAR_FULL }, | |
24 { 3.4, 3, IDR_CWS_STAR_HALF }, | |
25 { 3.4, 4, IDR_CWS_STAR_EMPTY }, | |
26 { -1.0, 0, IDR_CWS_STAR_EMPTY }, | |
27 { -1.0, 1, IDR_CWS_STAR_EMPTY }, | |
28 { -1.0, 2, IDR_CWS_STAR_EMPTY }, | |
29 { -1.0, 3, IDR_CWS_STAR_EMPTY }, | |
30 { -1.0, 4, IDR_CWS_STAR_EMPTY }, | |
31 { 6.0, 0, IDR_CWS_STAR_FULL }, | |
32 { 6.0, 1, IDR_CWS_STAR_FULL }, | |
33 { 6.0, 2, IDR_CWS_STAR_FULL }, | |
34 { 6.0, 3, IDR_CWS_STAR_FULL }, | |
35 { 6.0, 4, IDR_CWS_STAR_FULL }, | |
36 { 1.6, 0, IDR_CWS_STAR_FULL }, | |
37 { 1.6, 1, IDR_CWS_STAR_HALF }, | |
38 { 1.6, 2, IDR_CWS_STAR_EMPTY }, | |
39 { 1.6, 3, IDR_CWS_STAR_EMPTY }, | |
40 { 1.6, 4, IDR_CWS_STAR_EMPTY }, | |
41 { 4.2, 0, IDR_CWS_STAR_FULL }, | |
42 { 4.2, 1, IDR_CWS_STAR_FULL }, | |
43 { 4.2, 2, IDR_CWS_STAR_FULL }, | |
44 { 4.2, 3, IDR_CWS_STAR_FULL }, | |
45 { 4.2, 4, IDR_CWS_STAR_EMPTY }, | |
46 { 3.7, 0, IDR_CWS_STAR_FULL }, | |
47 { 3.7, 1, IDR_CWS_STAR_FULL }, | |
48 { 3.7, 2, IDR_CWS_STAR_FULL }, | |
49 { 3.7, 3, IDR_CWS_STAR_FULL }, | |
50 { 3.7, 4, IDR_CWS_STAR_EMPTY }, | |
51 }; | |
52 | |
53 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | |
54 EXPECT_EQ(test_cases[i].expected_star_image, | |
55 WebIntentPicker::GetNthStarImageIdFromCWSRating( | |
56 test_cases[i].rating, | |
57 test_cases[i].index)); | |
58 } | |
59 } | |
OLD | NEW |