diff options
author | smckay@chromium.org <smckay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-28 21:24:43 +0000 |
---|---|---|
committer | smckay@chromium.org <smckay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-28 21:24:43 +0000 |
commit | f928b89b660fe3ec965a19d784e80285c2957477 (patch) | |
tree | 28e86e8bec9a07e89db7121c70052d0873e13c51 /webkit | |
parent | 67037167af9c70a339e8d78ba2ee3287646bf6c0 (diff) | |
download | chromium_src-f928b89b660fe3ec965a19d784e80285c2957477.zip chromium_src-f928b89b660fe3ec965a19d784e80285c2957477.tar.gz chromium_src-f928b89b660fe3ec965a19d784e80285c2957477.tar.bz2 |
Add "scheme" field to WebIntentServiceData object.
Add unittest for web_intent_service_data.
Reorder constructor args to group service url with title.
BUG=129199
TEST=./out/Debug/unit_tests --gtest_filter=WebIntentServiceDataTest.*
+jamesr AND brettw for webkit_glue changes.
Review URL: https://chromiumcodereview.appspot.com/10541125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144800 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/web_intent_service_data.cc | 31 | ||||
-rw-r--r-- | webkit/glue/web_intent_service_data.h | 21 | ||||
-rw-r--r-- | webkit/glue/web_intent_service_data_unittest.cc | 82 |
3 files changed, 117 insertions, 17 deletions
diff --git a/webkit/glue/web_intent_service_data.cc b/webkit/glue/web_intent_service_data.cc index 4367b60..a9d1a0a 100644 --- a/webkit/glue/web_intent_service_data.cc +++ b/webkit/glue/web_intent_service_data.cc @@ -16,22 +16,25 @@ WebIntentServiceData::WebIntentServiceData() : disposition(WebIntentServiceData::DISPOSITION_WINDOW) { } -WebIntentServiceData::WebIntentServiceData(const GURL& svc_url, - const string16& svc_action, +WebIntentServiceData::WebIntentServiceData(const string16& svc_action, const string16& svc_type, + const string16& svc_scheme, + const GURL& svc_service_url, const string16& svc_title) - : service_url(svc_url), - action(svc_action), + : action(svc_action), type(svc_type), + scheme(svc_scheme), + service_url(svc_service_url), title(svc_title), disposition(WebIntentServiceData::DISPOSITION_WINDOW) { } WebIntentServiceData::WebIntentServiceData( const WebKit::WebIntentServiceInfo& info) - : service_url(info.url()), - action(info.action()), + : action(info.action()), type(info.type()), + scheme(string16()), + service_url(info.url()), title(info.title()), disposition(WebIntentServiceData::DISPOSITION_WINDOW) { setDisposition(info.disposition()); @@ -40,9 +43,10 @@ WebIntentServiceData::WebIntentServiceData( WebIntentServiceData::~WebIntentServiceData() {} bool WebIntentServiceData::operator==(const WebIntentServiceData& other) const { - return service_url == other.service_url && - action == other.action && + return action == other.action && type == other.type && + scheme == other.scheme && + service_url == other.service_url && title == other.title && disposition == other.disposition; } @@ -57,11 +61,12 @@ void WebIntentServiceData::setDisposition(const string16& disp) { std::ostream& operator<<(::std::ostream& os, const WebIntentServiceData& intent) { return os << - "{" << intent.service_url << - ", " << UTF16ToUTF8(intent.action) << - ", " << UTF16ToUTF8(intent.type) << - ", " << UTF16ToUTF8(intent.title) << - ", " << intent.disposition << + "{action=" << UTF16ToUTF8(intent.action) << + "type=, " << UTF16ToUTF8(intent.type) << + "scheme=, " << UTF16ToUTF8(intent.scheme) << + "service_url=, " << intent.service_url << + "title=, " << UTF16ToUTF8(intent.title) << + "disposition=, " << intent.disposition << "}"; } diff --git a/webkit/glue/web_intent_service_data.h b/webkit/glue/web_intent_service_data.h index d5a9136..4078541 100644 --- a/webkit/glue/web_intent_service_data.h +++ b/webkit/glue/web_intent_service_data.h @@ -27,9 +27,10 @@ struct WEBKIT_GLUE_EXPORT WebIntentServiceData { }; WebIntentServiceData(); - WebIntentServiceData(const GURL& service_url, - const string16& action, + WebIntentServiceData(const string16& action, const string16& type, + const string16& scheme, + const GURL& service_url, const string16& title); explicit WebIntentServiceData(const WebKit::WebIntentServiceInfo& info); ~WebIntentServiceData(); @@ -38,11 +39,23 @@ struct WEBKIT_GLUE_EXPORT WebIntentServiceData { void setDisposition(const string16& disp); - GURL service_url; // URL for service invocation. + // |action|+|type| forms one type of unique service key. The other is + // |scheme|. string16 action; // Name of action provided by service. string16 type; // MIME type of data accepted by service. + + // |scheme| forms one type of unique service key. The other is + // |action|+|type|. Note that this scheme is for purposes + // of matching intent services, not the scheme associated + // with the service_url. + string16 scheme; // Protocol scheme for intent service matching. + + GURL service_url; // URL for service invocation. string16 title; // The title of the service. - Disposition disposition; // The context the service is opened in. + + // Disposition specifies the way in which a service is surfaced to the user. + // Current supported dispositions are declared in the |Disposition| enum. + Disposition disposition; }; // Printing operator - helps gtest produce readable error messages. diff --git a/webkit/glue/web_intent_service_data_unittest.cc b/webkit/glue/web_intent_service_data_unittest.cc new file mode 100644 index 0000000..640496a --- /dev/null +++ b/webkit/glue/web_intent_service_data_unittest.cc @@ -0,0 +1,82 @@ +// Copyright (c) 2012 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 <string> + +#include "base/utf_string_conversions.h" +#include "googleurl/src/gurl.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "webkit/glue/web_intent_service_data.h" + +using webkit_glue::WebIntentServiceData; + +namespace { + +void Expect( + const std::string& action, + const std::string& type, + const std::string& scheme, + const std::string& url, + const std::string& title, + const WebIntentServiceData::Disposition disposition, + const WebIntentServiceData* intent) { + + EXPECT_EQ(GURL(url), intent->service_url); + EXPECT_EQ(ASCIIToUTF16(action), intent->action); + EXPECT_EQ(ASCIIToUTF16(type), intent->type); + EXPECT_EQ(ASCIIToUTF16(scheme), intent->scheme); + EXPECT_EQ(ASCIIToUTF16(title), intent->title); + EXPECT_EQ(disposition, intent->disposition); +} + +TEST(WebIntentServiceDataTest, Defaults) { + WebIntentServiceData intent; + EXPECT_EQ(string16(), intent.action); + EXPECT_EQ(string16(), intent.type); + EXPECT_EQ(string16(), intent.scheme); + EXPECT_EQ(string16(), intent.title); + EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, intent.disposition); +} + +TEST(WebIntentServiceDataTest, ActionServicesEqual) { + + // with default disposition... + WebIntentServiceData intent = WebIntentServiceData::WebIntentServiceData( + ASCIIToUTF16("http://webintents.org/share"), + ASCIIToUTF16("image/png"), + string16(), + GURL("http://abc.com/xyx.html"), + ASCIIToUTF16("Image Sharing Service")); + + Expect( + "http://webintents.org/share", + "image/png", + std::string(), + "http://abc.com/xyx.html", + "Image Sharing Service", + WebIntentServiceData::DISPOSITION_WINDOW, + &intent); +} + +TEST(WebIntentServiceDataTest, SchemeServicesEqual) { + + // with default disposition... + WebIntentServiceData intent = WebIntentServiceData::WebIntentServiceData( + string16(), + string16(), + ASCIIToUTF16("mailto"), + GURL("http://abc.com/xyx.html"), + ASCIIToUTF16("Image Sharing Service")); + + Expect( + "", + "", + "mailto", + "http://abc.com/xyx.html", + "Image Sharing Service", + WebIntentServiceData::DISPOSITION_WINDOW, + &intent); +} + +} // namespace |