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

Unified Diff: chrome/browser/intents/web_intents_registry_unittest.cc

Issue 9430027: Add default query method to WebIntentsRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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: chrome/browser/intents/web_intents_registry_unittest.cc
diff --git a/chrome/browser/intents/web_intents_registry_unittest.cc b/chrome/browser/intents/web_intents_registry_unittest.cc
index 03a33c8e62a35c39d03c992a96420583125a028e..d2199f7c8bf72b9ecb39d586c1129ef9d9b8508d 100644
--- a/chrome/browser/intents/web_intents_registry_unittest.cc
+++ b/chrome/browser/intents/web_intents_registry_unittest.cc
@@ -9,6 +9,7 @@
#include "base/scoped_temp_dir.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/test_extension_service.h"
+#include "chrome/browser/intents/default_web_intent_service.h"
#include "chrome/browser/intents/web_intents_registry.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_paths.h"
@@ -127,6 +128,16 @@ class TestConsumer: public WebIntentsRegistry::Consumer {
MessageLoop::current()->Quit();
}
+ virtual void OnIntentsDefaultsQueryDone(
+ WebIntentsRegistry::QueryID id,
+ const DefaultWebIntentService& default_service) {
+ DCHECK(id == expected_id_);
+ default_ = default_service;
+
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ MessageLoop::current()->Quit();
+ }
+
// Wait for the UI message loop to terminate - happens when OnIntesQueryDone
// is invoked.
void WaitForData() {
@@ -139,6 +150,9 @@ class TestConsumer: public WebIntentsRegistry::Consumer {
// Result data from callback.
std::vector<webkit_glue::WebIntentServiceData> services_;
+
+ // Result default data from callback.
+ DefaultWebIntentService default_;
};
TEST_F(WebIntentsRegistryTest, BasicTests) {
@@ -327,3 +341,51 @@ TEST_F(WebIntentsRegistryTest, GetIntentsWithMimeMatching) {
EXPECT_EQ(services[2], consumer.services_[2]);
EXPECT_EQ(services[3], consumer.services_[3]);
}
+
+TEST_F(WebIntentsRegistryTest, TestGetDefaults) {
+ DefaultWebIntentService default_service;
+ default_service.action = ASCIIToUTF16("share");
+ default_service.type = ASCIIToUTF16("type/*");
+ default_service.user_date = 1;
+ default_service.suppression = 4;
groby-ooo-7-16 2012/02/22 01:40:18 What does user_date = 1 and suppression = 4 mean?
Greg Billock 2012/02/23 23:39:00 Nothing. Just filler to make sure they're preserve
+ default_service.service_url = "service_url";
+ registry_.RegisterDefaultIntentService(default_service);
+
+ TestConsumer consumer;
+
+ consumer.expected_id_ = registry_.GetDefaultIntentService(
+ ASCIIToUTF16("share"),
+ ASCIIToUTF16("type/plain"),
+ GURL("http://www.google.com/"),
+ &consumer);
+
+ consumer.WaitForData();
+
+ EXPECT_EQ("service_url", consumer.default_.service_url);
+ EXPECT_EQ(1, consumer.default_.user_date);
+ EXPECT_EQ(4, consumer.default_.suppression);
+
+ consumer.default_ = DefaultWebIntentService();
groby-ooo-7-16 2012/02/22 01:40:18 Can you comment the test cases? I.e. "Retrieve exi
Greg Billock 2012/02/23 23:39:00 Done.
+ ASSERT_EQ("", consumer.default_.service_url);
+ consumer.expected_id_ = registry_.GetDefaultIntentService(
+ ASCIIToUTF16("no-share"),
+ ASCIIToUTF16("type/plain"),
+ GURL("http://www.google.com/"),
+ &consumer);
+
+ consumer.WaitForData();
+
+ EXPECT_EQ("", consumer.default_.service_url);
+
+ consumer.default_ = DefaultWebIntentService();
+ ASSERT_EQ("", consumer.default_.service_url);
+ consumer.expected_id_ = registry_.GetDefaultIntentService(
+ ASCIIToUTF16("share"),
+ ASCIIToUTF16("notype/plain"),
+ GURL("http://www.google.com/"),
+ &consumer);
+
+ consumer.WaitForData();
+
+ EXPECT_EQ("", consumer.default_.service_url);
+}

Powered by Google App Engine
This is Rietveld 408576698