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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/api/notifications/notifications_api.h" 8 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_function_test_utils.h" 10 #include "chrome/browser/extensions/extension_function_test_utils.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 382
383 { 383 {
384 ResultCatcher catcher; 384 ResultCatcher catcher;
385 g_browser_process->message_center()->RemoveNotification( 385 g_browser_process->message_center()->RemoveNotification(
386 extension->id() + "-BAR", 386 extension->id() + "-BAR",
387 true); 387 true);
388 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 388 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
389 } 389 }
390 } 390 }
391
392
393 #if defined(OS_LINUX)
394 #define MAYBE_TestProgressNotification DISABLED_TestProgressNotification
395 #else
396 #define MAYBE_TestProgressNotification TestProgressNotification
397 #endif
398
399 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestProgressNotification) {
400 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
401
402 {
403 scoped_refptr<extensions::NotificationsCreateFunction>
404 notification_create_function(
405 new extensions::NotificationsCreateFunction());
406 notification_create_function->set_extension(empty_extension.get());
407 notification_create_function->set_has_callback(true);
408
409 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
410 notification_create_function.get(),
411 "[\"\", "
412 "{"
413 "\"type\": \"progress\","
414 "\"iconUrl\": \"an/image/that/does/not/exist.png\","
415 "\"title\": \"Test!\","
416 "\"message\": \"This is a progress notification.\","
417 "\"priority\": 1,"
418 "\"eventTime\": 1234567890.12345678,"
419 "\"progress\": 30"
420 "}]",
421 browser(),
422 utils::NONE));
423
424 std::string notification_id;
425 EXPECT_EQ(base::Value::TYPE_STRING, result->GetType());
426 EXPECT_TRUE(result->GetAsString(&notification_id));
427 EXPECT_TRUE(notification_id.length() > 0);
428 }
429
430 // Error case: progress value provided for non-progress type.
431 {
432 scoped_refptr<extensions::NotificationsCreateFunction>
433 notification_create_function(
434 new extensions::NotificationsCreateFunction());
435 notification_create_function->set_extension(empty_extension.get());
436 notification_create_function->set_has_callback(true);
437
438 utils::RunFunction(
439 notification_create_function.get(),
440 "[\"\", "
441 "{"
442 "\"type\": \"basic\","
443 "\"iconUrl\": \"an/image/that/does/not/exist.png\","
444 "\"title\": \"Test!\","
445 "\"message\": \"This is a progress notification.\","
446 "\"priority\": 1,"
447 "\"eventTime\": 1234567890.12345678,"
448 "\"progress\": 10"
449 "}]",
450 browser(),
451 utils::NONE);
452 EXPECT_FALSE(notification_create_function->GetError().empty());
453 }
454
455 // Error case: progress value less than lower bound.
456 {
457 scoped_refptr<extensions::NotificationsCreateFunction>
458 notification_create_function(
459 new extensions::NotificationsCreateFunction());
460 notification_create_function->set_extension(empty_extension.get());
461 notification_create_function->set_has_callback(true);
462
463 utils::RunFunction(
464 notification_create_function.get(),
465 "[\"\", "
466 "{"
467 "\"type\": \"progress\","
468 "\"iconUrl\": \"an/image/that/does/not/exist.png\","
469 "\"title\": \"Test!\","
470 "\"message\": \"This is a progress notification.\","
471 "\"priority\": 1,"
472 "\"eventTime\": 1234567890.12345678,"
473 "\"progress\": -10"
474 "}]",
475 browser(),
476 utils::NONE);
477 EXPECT_FALSE(notification_create_function->GetError().empty());
478 }
479
480 // Error case: progress value greater than upper bound.
481 {
482 scoped_refptr<extensions::NotificationsCreateFunction>
483 notification_create_function(
484 new extensions::NotificationsCreateFunction());
485 notification_create_function->set_extension(empty_extension.get());
486 notification_create_function->set_has_callback(true);
487
488 utils::RunFunction(
489 notification_create_function.get(),
490 "[\"\", "
491 "{"
492 "\"type\": \"progress\","
493 "\"iconUrl\": \"an/image/that/does/not/exist.png\","
494 "\"title\": \"Test!\","
495 "\"message\": \"This is a progress notification.\","
496 "\"priority\": 1,"
497 "\"eventTime\": 1234567890.12345678,"
498 "\"progress\": 101"
499 "}]",
500 browser(),
501 utils::NONE);
502 EXPECT_FALSE(notification_create_function->GetError().empty());
503 }
504 }
OLDNEW
« 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