Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2006-2009 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 "chrome/browser/icon_url_data_manager.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 class IconURITest : public testing:: Test { | |
| 10 }; | |
| 11 | |
| 12 TEST(IconURITest, ParseIconURITest) { | |
| 13 typedef struct { | |
| 14 GURL url; | |
| 15 const char* expected_extension; | |
| 16 const char* expected_media_type; | |
| 17 const char* expected_keyword; | |
| 18 int expected_size; | |
| 19 } TestData; | |
| 20 | |
| 21 TestData passingTests[] = { | |
| 22 { GURL("icon:"), "", "", "unknown", 16 }, | |
| 23 { GURL("ICON:;"), "", "", "unknown", 16 }, | |
| 24 { GURL("icon:;medium"), "", "", "unknown", 64 }, | |
| 25 { GURL("icon:.zip"), ".zip", "", "", 16 }, | |
| 26 { GURL("icon:.MP3;32"), ".mp3", "", "", 32 }, | |
| 27 { GURL("icon:unknown"), "", "", "unknown", 16 }, | |
| 28 { GURL("icon:directory;64"), "", "", "directory", 64 }, | |
| 29 { GURL("icon:image:jpeg;128"), "", "image/jpeg", "", 128 }, | |
| 30 { GURL("icon:AUDIO:MPEG;large"), "", "audio/mpeg", "", 256 }, | |
| 31 { GURL("icon:.doc;SMALL"), ".doc", "", "", 16 }, | |
| 32 { GURL("icon:.pdf;medium"), ".pdf", "", "", 64 }, | |
| 33 }; | |
| 34 | |
| 35 // IconURI should return a default unknown 16x16 icon for invalid URI. | |
| 36 TestData failingTests[] = { | |
| 37 { GURL(""), "", "", "unknown", 16 }, | |
| 38 { GURL("http://www.google.com"), "", "", "unknown", 16 }, | |
| 39 { GURL("ico:.mp3"), "", "", "unknown", 16 }, | |
| 40 }; | |
| 41 | |
| 42 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(passingTests); ++i) { | |
|
Paweł Hajdan Jr.
2010/09/08 17:51:44
Please use SCOPED_TRACE in the loops (here and bel
| |
| 43 IconURI icon_uri; | |
| 44 icon_uri.ParseIconURI(passingTests[i].url); | |
| 45 | |
| 46 EXPECT_TRUE(icon_uri.IsValid()); | |
| 47 EXPECT_EQ(std::string(passingTests[i].expected_extension), | |
| 48 icon_uri.extension()); | |
| 49 EXPECT_EQ(std::string(passingTests[i].expected_media_type), | |
| 50 icon_uri.media_type()); | |
| 51 EXPECT_EQ(std::string(passingTests[i].expected_keyword), | |
| 52 icon_uri.keyword()); | |
| 53 EXPECT_EQ(passingTests[i].expected_size, icon_uri.size()); | |
| 54 } | |
| 55 | |
| 56 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(failingTests); ++i) { | |
| 57 IconURI icon_uri; | |
| 58 icon_uri.ParseIconURI(failingTests[i].url); | |
| 59 | |
| 60 EXPECT_FALSE(icon_uri.IsValid()); | |
| 61 EXPECT_EQ(std::string(failingTests[i].expected_extension), | |
| 62 icon_uri.extension()); | |
| 63 EXPECT_EQ(std::string(failingTests[i].expected_media_type), | |
| 64 icon_uri.media_type()); | |
| 65 EXPECT_EQ(std::string(failingTests[i].expected_keyword), | |
| 66 icon_uri.keyword()); | |
| 67 EXPECT_EQ(failingTests[i].expected_size, icon_uri.size()); | |
| 68 } | |
| 69 } | |
| OLD | NEW |