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

Unified Diff: chrome/browser/extensions/api/notifications/notifications_apitest.cc

Issue 18662006: Support creating progress bar notification for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test for Linux Created 7 years, 5 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/extensions/api/notifications/notifications_apitest.cc
diff --git a/chrome/browser/extensions/api/notifications/notifications_apitest.cc b/chrome/browser/extensions/api/notifications/notifications_apitest.cc
index 9320262864e2c43b53ea263e9833944bf0756b69..b89e96707395032a467502afbb3bb453f988ff3f 100644
--- a/chrome/browser/extensions/api/notifications/notifications_apitest.cc
+++ b/chrome/browser/extensions/api/notifications/notifications_apitest.cc
@@ -388,3 +388,117 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestByUser) {
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
}
+
+
+#if defined(OS_LINUX)
+#define MAYBE_TestProgressNotification DISABLED_TestProgressNotification
+#else
+#define MAYBE_TestProgressNotification TestProgressNotification
+#endif
+
+IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestProgressNotification) {
+ scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
+
+ {
+ scoped_refptr<extensions::NotificationsCreateFunction>
+ notification_create_function(
+ new extensions::NotificationsCreateFunction());
+ notification_create_function->set_extension(empty_extension.get());
+ notification_create_function->set_has_callback(true);
+
+ scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
+ notification_create_function.get(),
+ "[\"\", "
+ "{"
+ "\"type\": \"progress\","
+ "\"iconUrl\": \"an/image/that/does/not/exist.png\","
+ "\"title\": \"Test!\","
+ "\"message\": \"This is a progress notification.\","
+ "\"priority\": 1,"
+ "\"eventTime\": 1234567890.12345678,"
+ "\"progress\": 30"
+ "}]",
+ browser(),
+ utils::NONE));
+
+ std::string notification_id;
+ EXPECT_EQ(base::Value::TYPE_STRING, result->GetType());
+ EXPECT_TRUE(result->GetAsString(&notification_id));
+ EXPECT_TRUE(notification_id.length() > 0);
+ }
+
+ // Error case: progress value provided for non-progress type.
+ {
+ scoped_refptr<extensions::NotificationsCreateFunction>
+ notification_create_function(
+ new extensions::NotificationsCreateFunction());
+ notification_create_function->set_extension(empty_extension.get());
+ notification_create_function->set_has_callback(true);
+
+ utils::RunFunction(
+ notification_create_function.get(),
+ "[\"\", "
+ "{"
+ "\"type\": \"basic\","
+ "\"iconUrl\": \"an/image/that/does/not/exist.png\","
+ "\"title\": \"Test!\","
+ "\"message\": \"This is a progress notification.\","
+ "\"priority\": 1,"
+ "\"eventTime\": 1234567890.12345678,"
+ "\"progress\": 10"
+ "}]",
+ browser(),
+ utils::NONE);
+ EXPECT_FALSE(notification_create_function->GetError().empty());
+ }
+
+ // Error case: progress value less than lower bound.
+ {
+ scoped_refptr<extensions::NotificationsCreateFunction>
+ notification_create_function(
+ new extensions::NotificationsCreateFunction());
+ notification_create_function->set_extension(empty_extension.get());
+ notification_create_function->set_has_callback(true);
+
+ utils::RunFunction(
+ notification_create_function.get(),
+ "[\"\", "
+ "{"
+ "\"type\": \"progress\","
+ "\"iconUrl\": \"an/image/that/does/not/exist.png\","
+ "\"title\": \"Test!\","
+ "\"message\": \"This is a progress notification.\","
+ "\"priority\": 1,"
+ "\"eventTime\": 1234567890.12345678,"
+ "\"progress\": -10"
+ "}]",
+ browser(),
+ utils::NONE);
+ EXPECT_FALSE(notification_create_function->GetError().empty());
+ }
+
+ // Error case: progress value greater than upper bound.
+ {
+ scoped_refptr<extensions::NotificationsCreateFunction>
+ notification_create_function(
+ new extensions::NotificationsCreateFunction());
+ notification_create_function->set_extension(empty_extension.get());
+ notification_create_function->set_has_callback(true);
+
+ utils::RunFunction(
+ notification_create_function.get(),
+ "[\"\", "
+ "{"
+ "\"type\": \"progress\","
+ "\"iconUrl\": \"an/image/that/does/not/exist.png\","
+ "\"title\": \"Test!\","
+ "\"message\": \"This is a progress notification.\","
+ "\"priority\": 1,"
+ "\"eventTime\": 1234567890.12345678,"
+ "\"progress\": 101"
+ "}]",
+ browser(),
+ utils::NONE);
+ EXPECT_FALSE(notification_create_function->GetError().empty());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698