Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Unified Diff: chrome/browser/icon_url_data_manager_unittest.cc

Issue 3324009: Work in progress implementation of Icon URI scheme. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/icon_url_data_manager.cc ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/icon_url_data_manager_unittest.cc
diff --git a/chrome/browser/icon_url_data_manager_unittest.cc b/chrome/browser/icon_url_data_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..01a28064fe378f15b02fd5a0eab39578cd9482ec
--- /dev/null
+++ b/chrome/browser/icon_url_data_manager_unittest.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/icon_url_data_manager.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+class IconURITest : public testing:: Test {
+};
+
+TEST(IconURITest, ParseIconURITest) {
+ typedef struct {
+ GURL url;
+ const char* expected_extension;
+ const char* expected_media_type;
+ const char* expected_keyword;
+ int expected_size;
+ } TestData;
+
+ TestData passingTests[] = {
+ { GURL("icon:"), "", "", "unknown", 16 },
+ { GURL("ICON:;"), "", "", "unknown", 16 },
+ { GURL("icon:;medium"), "", "", "unknown", 64 },
+ { GURL("icon:.zip"), ".zip", "", "", 16 },
+ { GURL("icon:.MP3;32"), ".mp3", "", "", 32 },
+ { GURL("icon:unknown"), "", "", "unknown", 16 },
+ { GURL("icon:directory;64"), "", "", "directory", 64 },
+ { GURL("icon:image:jpeg;128"), "", "image/jpeg", "", 128 },
+ { GURL("icon:AUDIO:MPEG;large"), "", "audio/mpeg", "", 256 },
+ { GURL("icon:.doc;SMALL"), ".doc", "", "", 16 },
+ { GURL("icon:.pdf;medium"), ".pdf", "", "", 64 },
+ };
+
+ // IconURI should return a default unknown 16x16 icon for invalid URI.
+ TestData failingTests[] = {
+ { GURL(""), "", "", "unknown", 16 },
+ { GURL("http://www.google.com"), "", "", "unknown", 16 },
+ { GURL("ico:.mp3"), "", "", "unknown", 16 },
+ };
+
+ 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
+ IconURI icon_uri;
+ icon_uri.ParseIconURI(passingTests[i].url);
+
+ EXPECT_TRUE(icon_uri.IsValid());
+ EXPECT_EQ(std::string(passingTests[i].expected_extension),
+ icon_uri.extension());
+ EXPECT_EQ(std::string(passingTests[i].expected_media_type),
+ icon_uri.media_type());
+ EXPECT_EQ(std::string(passingTests[i].expected_keyword),
+ icon_uri.keyword());
+ EXPECT_EQ(passingTests[i].expected_size, icon_uri.size());
+ }
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(failingTests); ++i) {
+ IconURI icon_uri;
+ icon_uri.ParseIconURI(failingTests[i].url);
+
+ EXPECT_FALSE(icon_uri.IsValid());
+ EXPECT_EQ(std::string(failingTests[i].expected_extension),
+ icon_uri.extension());
+ EXPECT_EQ(std::string(failingTests[i].expected_media_type),
+ icon_uri.media_type());
+ EXPECT_EQ(std::string(failingTests[i].expected_keyword),
+ icon_uri.keyword());
+ EXPECT_EQ(failingTests[i].expected_size, icon_uri.size());
+ }
+}
« no previous file with comments | « chrome/browser/icon_url_data_manager.cc ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698