OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/renderer/web_apps.h" | 5 #include "chrome/renderer/web_apps.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 // Tests ParseIconSizes with various input. | 10 // Tests ParseIconSizes with various input. |
(...skipping 22 matching lines...) Expand all Loading... |
33 // Any. | 33 // Any. |
34 { "any", true, true, 0, 0, 0, 0, 0 }, | 34 { "any", true, true, 0, 0, 0, 0, 0 }, |
35 { " any", true, true, 0, 0, 0, 0, 0 }, | 35 { " any", true, true, 0, 0, 0, 0, 0 }, |
36 { " any ", true, true, 0, 0, 0, 0, 0 }, | 36 { " any ", true, true, 0, 0, 0, 0, 0 }, |
37 | 37 |
38 // Sizes. | 38 // Sizes. |
39 { "10x11", true, false, 1, 10, 11, 0, 0 }, | 39 { "10x11", true, false, 1, 10, 11, 0, 0 }, |
40 { " 10x11 ", true, false, 1, 10, 11, 0, 0 }, | 40 { " 10x11 ", true, false, 1, 10, 11, 0, 0 }, |
41 { " 10x11 1x2", true, false, 2, 10, 11, 1, 2 }, | 41 { " 10x11 1x2", true, false, 2, 10, 11, 1, 2 }, |
42 }; | 42 }; |
43 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 43 for (size_t i = 0; i < arraysize(data); ++i) { |
44 bool is_any; | 44 bool is_any; |
45 std::vector<gfx::Size> sizes; | 45 std::vector<gfx::Size> sizes; |
46 bool result = web_apps::ParseIconSizes( | 46 bool result = web_apps::ParseIconSizes( |
47 base::ASCIIToUTF16(data[i].input), &sizes, &is_any); | 47 base::ASCIIToUTF16(data[i].input), &sizes, &is_any); |
48 ASSERT_EQ(result, data[i].expected_result); | 48 ASSERT_EQ(result, data[i].expected_result); |
49 if (result) { | 49 if (result) { |
50 ASSERT_EQ(data[i].is_any, is_any); | 50 ASSERT_EQ(data[i].is_any, is_any); |
51 ASSERT_EQ(data[i].expected_size_count, sizes.size()); | 51 ASSERT_EQ(data[i].expected_size_count, sizes.size()); |
52 if (!sizes.empty()) { | 52 if (!sizes.empty()) { |
53 ASSERT_EQ(data[i].width1, sizes[0].width()); | 53 ASSERT_EQ(data[i].width1, sizes[0].width()); |
54 ASSERT_EQ(data[i].height1, sizes[0].height()); | 54 ASSERT_EQ(data[i].height1, sizes[0].height()); |
55 } | 55 } |
56 if (sizes.size() > 1) { | 56 if (sizes.size() > 1) { |
57 ASSERT_EQ(data[i].width2, sizes[1].width()); | 57 ASSERT_EQ(data[i].width2, sizes[1].width()); |
58 ASSERT_EQ(data[i].height2, sizes[1].height()); | 58 ASSERT_EQ(data[i].height2, sizes[1].height()); |
59 } | 59 } |
60 } | 60 } |
61 } | 61 } |
62 } | 62 } |
OLD | NEW |