Chromium Code Reviews| 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 e84c10ab02cd8c89f177442377bd3472975cc9e2..694d21df0090959caf13b0f72f313402681e2e5d 100644 |
| --- a/chrome/browser/extensions/api/notifications/notifications_apitest.cc |
| +++ b/chrome/browser/extensions/api/notifications/notifications_apitest.cc |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/stringprintf.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
| #include "chrome/browser/extensions/extension_apitest.h" |
| @@ -12,6 +13,7 @@ |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/test/test_utils.h" |
| #include "ui/message_center/message_center.h" |
| +#include "ui/message_center/message_center_switches.h" |
| #include "ui/message_center/message_center_util.h" |
| // TODO(kbr): remove: http://crbug.com/222296 |
| @@ -260,6 +262,77 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestMultipleItemNotification) { |
| ASSERT_TRUE(notification_id.length() > 0); |
| } |
| +IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestGetAll) { |
| + scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
| + |
| + { |
| + scoped_refptr<extensions::NotificationsGetAllFunction> |
| + notification_get_all_function( |
| + new extensions::NotificationsGetAllFunction()); |
| + notification_get_all_function->set_extension(empty_extension.get()); |
| + notification_get_all_function->set_has_callback(true); |
| + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
| + notification_get_all_function, "[]", browser(), utils::NONE)); |
| + |
| + base::DictionaryValue* return_value; |
| + ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); |
| + ASSERT_TRUE(result->GetAsDictionary(&return_value)); |
| + ASSERT_TRUE(return_value->size() == 0); |
| + } |
| + |
| + const unsigned int kNotificationsToCreate = 4; |
| + |
| + for (unsigned int i = 0; i < kNotificationsToCreate; i++) { |
| + 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, |
| + base::StringPrintf("[\"identifier-%u\", " |
| + "{" |
| + "\"type\": \"list\"," |
| + "\"iconUrl\": \"an/image/that/does/not/exist.png\"," |
| + "\"title\": \"Title\"," |
| + "\"message\": \"Message.\"," |
| + "\"items\": [" |
| + " {\"title\": \"Grace Goe\"," |
| + " \"message\": \"I saw Frank steal a sandwich :-)\"}" |
| + "]," |
| + "\"priority\": 1," |
| + "\"eventTime\": 1361488019.9999999" |
| + "}]", |
| + i), |
| + browser(), |
| + utils::NONE)); |
| + } |
| + |
| + { |
| + scoped_refptr<extensions::NotificationsGetAllFunction> |
| + notification_get_all_function( |
| + new extensions::NotificationsGetAllFunction()); |
| + notification_get_all_function->set_extension(empty_extension.get()); |
| + notification_get_all_function->set_has_callback(true); |
| + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
| + notification_get_all_function, "[]", browser(), utils::NONE)); |
| + |
| + base::DictionaryValue* return_value; |
| + ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); |
| + ASSERT_TRUE(result->GetAsDictionary(&return_value)); |
| + ASSERT_EQ(return_value->size(), kNotificationsToCreate); |
| + bool dictionary_bool = false; |
| + for (unsigned int i = 0; i < kNotificationsToCreate; i++) { |
| + std::string id = base::StringPrintf("identifier-%u", i); |
| + ASSERT_TRUE(return_value->GetBoolean(id, &dictionary_bool)); |
| + ASSERT_TRUE(dictionary_bool); |
| + } |
| + ASSERT_FALSE(return_value->GetBoolean("test", &dictionary_bool)); |
|
Dmitry Titov
2013/05/16 20:39:15
What does this line check?
dewittj
2013/05/16 23:40:34
Probably it is unnecessary but I was checking that
|
| + } |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestEvents) { |
| #if defined(OS_MACOSX) |
| // TODO(kbr): re-enable: http://crbug.com/222296 |