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

Unified Diff: Source/modules/navigatorcontentutils/testing/NavigatorContentUtilsClientMock.cpp

Issue 293403002: Introduce mock test system for navigator content utils (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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
Index: Source/modules/navigatorcontentutils/testing/NavigatorContentUtilsClientMock.cpp
diff --git a/Source/platform/weborigin/KURLHash.h b/Source/modules/navigatorcontentutils/testing/NavigatorContentUtilsClientMock.cpp
similarity index 51%
copy from Source/platform/weborigin/KURLHash.h
copy to Source/modules/navigatorcontentutils/testing/NavigatorContentUtilsClientMock.cpp
index 47d234582914cafdc55157d34b9a294b7dab066e..4cb91d71678ad8d7d94ad975a059ac1935b8d5ac 100644
--- a/Source/platform/weborigin/KURLHash.h
+++ b/Source/modules/navigatorcontentutils/testing/NavigatorContentUtilsClientMock.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2014 Samsung Electronics. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,35 +23,41 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef KURLHash_h
-#define KURLHash_h
+#include "config.h"
+#include "NavigatorContentUtilsClientMock.h"
-#include "platform/weborigin/KURL.h"
+#include "modules/navigatorcontentutils/NavigatorContentUtilsClient.h"
+#include "wtf/PassOwnPtr.h"
#include "wtf/text/StringHash.h"
-#include "wtf/text/WTFString.h"
namespace WebCore {
-struct KURLHash {
- static unsigned hash(const KURL& key)
- {
- return key.string().impl()->hash();
- }
-
- static bool equal(const KURL& a, const KURL& b)
- {
- return StringHash::equal(a.string(), b.string());
- }
-
- static const bool safeToCompareToEmptyOrDeleted = false;
-};
-
-} // namespace WebCore
-
-namespace WTF {
-
-template<> struct HashTraits<WebCore::KURL> : SimpleClassHashTraits<WebCore::KURL> { };
-
-} // namespace WTF
-
-#endif // KURLHash_h
+void NavigatorContentUtilsClientMock::registerProtocolHandler(const String& scheme, const WebCore::KURL& baseURL,
+ const WebCore::KURL& url, const String& title)
+{
+ ProtocolInfo info;
+ info.scheme = scheme;
+ info.baseURL = baseURL;
+ info.url = url;
+ info.title = title;
+
+ m_protocolMap.set(scheme, info);
+}
+
+NavigatorContentUtilsClient::CustomHandlersState NavigatorContentUtilsClientMock::isProtocolHandlerRegistered(const String& scheme,
+ const WebCore::KURL& baseURL, const WebCore::KURL& url)
+{
+ // "declined" state was checked by NavigatorContentUtils::isProtocolHandlerRegistered() before calling this function.
+ if (m_protocolMap.contains(scheme))
+ return NavigatorContentUtilsClient::CustomHandlersRegistered;
+
+ return NavigatorContentUtilsClient::CustomHandlersNew;
+}
+
+void NavigatorContentUtilsClientMock::unregisterProtocolHandler(const String& scheme, const WebCore::KURL& baseURL,
+ const WebCore::KURL& url)
+{
+ m_protocolMap.remove(scheme);
+}
+
+} // WebCore

Powered by Google App Engine
This is Rietveld 408576698