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

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: Fix per feedbacks 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 3a6e2b218c9598bc95315f1fcfe465a56849f325..5ea2a9fa1296b6b6a5e0b5b77ef523f2cb83fb88 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());
+ }
+}
« no previous file with comments | « chrome/browser/extensions/api/notifications/notifications_api.cc ('k') | chrome/common/extensions/api/notifications.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698