| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 return; | 276 return; |
| 277 #endif | 277 #endif |
| 278 | 278 |
| 279 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); | 279 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); |
| 280 TestAddObserver observer(message_center()); | 280 TestAddObserver observer(message_center()); |
| 281 | 281 |
| 282 TestDelegate* delegate; | 282 TestDelegate* delegate; |
| 283 TestDelegate* delegate2; | 283 TestDelegate* delegate2; |
| 284 | 284 |
| 285 manager()->Add(CreateTestNotification("n", &delegate), profile()); | 285 manager()->Add(CreateTestNotification("n", &delegate), profile()); |
| 286 message_center()->SetMessageCenterVisible(true); | 286 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
| 287 manager()->Add(CreateTestNotification("n2", &delegate2), profile()); | 287 manager()->Add(CreateTestNotification("n2", &delegate2), profile()); |
| 288 | 288 |
| 289 EXPECT_EQ("add-n", observer.log()); | 289 EXPECT_EQ("add-n", observer.log()); |
| 290 | 290 |
| 291 message_center()->SetMessageCenterVisible(false); | 291 message_center()->SetVisibility(message_center::VISIBILITY_TRANSIENT); |
| 292 | 292 |
| 293 EXPECT_EQ("add-n_add-n2", observer.log()); | 293 EXPECT_EQ("add-n_add-n2", observer.log()); |
| 294 | 294 |
| 295 delegate->Release(); | 295 delegate->Release(); |
| 296 delegate2->Release(); | 296 delegate2->Release(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 // MessaceCenter-specific test. | 299 // MessaceCenter-specific test. |
| 300 #if defined(RUN_MESSAGE_CENTER_TESTS) | 300 #if defined(RUN_MESSAGE_CENTER_TESTS) |
| 301 #define MAYBE_UpdateNonProgressNotificationWhenCenterVisible \ | 301 #define MAYBE_UpdateNonProgressNotificationWhenCenterVisible \ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 316 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); | 316 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); |
| 317 TestAddObserver observer(message_center()); | 317 TestAddObserver observer(message_center()); |
| 318 | 318 |
| 319 TestDelegate* delegate; | 319 TestDelegate* delegate; |
| 320 | 320 |
| 321 // Add a non-progress notification and update it while the message center | 321 // Add a non-progress notification and update it while the message center |
| 322 // is visible. | 322 // is visible. |
| 323 Notification notification = CreateTestNotification("n", &delegate); | 323 Notification notification = CreateTestNotification("n", &delegate); |
| 324 manager()->Add(notification, profile()); | 324 manager()->Add(notification, profile()); |
| 325 message_center()->ClickOnNotification("n"); | 325 message_center()->ClickOnNotification("n"); |
| 326 message_center()->SetMessageCenterVisible(true); | 326 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
| 327 observer.reset_log(); | 327 observer.reset_log(); |
| 328 notification.set_title(ASCIIToUTF16("title2")); | 328 notification.set_title(ASCIIToUTF16("title2")); |
| 329 manager()->Update(notification, profile()); | 329 manager()->Update(notification, profile()); |
| 330 | 330 |
| 331 // Expect that the notification update is not done. | 331 // Expect that the notification update is not done. |
| 332 EXPECT_EQ("", observer.log()); | 332 EXPECT_EQ("", observer.log()); |
| 333 | 333 |
| 334 delegate->Release(); | 334 delegate->Release(); |
| 335 } | 335 } |
| 336 | 336 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 355 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); | 355 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); |
| 356 TestAddObserver observer(message_center()); | 356 TestAddObserver observer(message_center()); |
| 357 | 357 |
| 358 TestDelegate* delegate; | 358 TestDelegate* delegate; |
| 359 | 359 |
| 360 // Add a non-progress notification and change the type to progress while the | 360 // Add a non-progress notification and change the type to progress while the |
| 361 // message center is visible. | 361 // message center is visible. |
| 362 Notification notification = CreateTestNotification("n", &delegate); | 362 Notification notification = CreateTestNotification("n", &delegate); |
| 363 manager()->Add(notification, profile()); | 363 manager()->Add(notification, profile()); |
| 364 message_center()->ClickOnNotification("n"); | 364 message_center()->ClickOnNotification("n"); |
| 365 message_center()->SetMessageCenterVisible(true); | 365 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
| 366 observer.reset_log(); | 366 observer.reset_log(); |
| 367 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS); | 367 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS); |
| 368 manager()->Update(notification, profile()); | 368 manager()->Update(notification, profile()); |
| 369 | 369 |
| 370 // Expect that the notification update is not done. | 370 // Expect that the notification update is not done. |
| 371 EXPECT_EQ("", observer.log()); | 371 EXPECT_EQ("", observer.log()); |
| 372 | 372 |
| 373 delegate->Release(); | 373 delegate->Release(); |
| 374 } | 374 } |
| 375 | 375 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 394 TestAddObserver observer(message_center()); | 394 TestAddObserver observer(message_center()); |
| 395 | 395 |
| 396 TestDelegate* delegate; | 396 TestDelegate* delegate; |
| 397 | 397 |
| 398 // Add a progress notification and update it while the message center | 398 // Add a progress notification and update it while the message center |
| 399 // is visible. | 399 // is visible. |
| 400 Notification notification = CreateTestNotification("n", &delegate); | 400 Notification notification = CreateTestNotification("n", &delegate); |
| 401 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS); | 401 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS); |
| 402 manager()->Add(notification, profile()); | 402 manager()->Add(notification, profile()); |
| 403 message_center()->ClickOnNotification("n"); | 403 message_center()->ClickOnNotification("n"); |
| 404 message_center()->SetMessageCenterVisible(true); | 404 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
| 405 observer.reset_log(); | 405 observer.reset_log(); |
| 406 notification.set_progress(50); | 406 notification.set_progress(50); |
| 407 manager()->Update(notification, profile()); | 407 manager()->Update(notification, profile()); |
| 408 | 408 |
| 409 // Expect that the progress notification update is performed. | 409 // Expect that the progress notification update is performed. |
| 410 EXPECT_EQ("update-n", observer.log()); | 410 EXPECT_EQ("update-n", observer.log()); |
| 411 | 411 |
| 412 delegate->Release(); | 412 delegate->Release(); |
| 413 } | 413 } |
| 414 | 414 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 431 // Cast so that Observe() is public. | 431 // Cast so that Observe() is public. |
| 432 content::NotificationObserver* observer = | 432 content::NotificationObserver* observer = |
| 433 static_cast<content::NotificationObserver*>(manager()); | 433 static_cast<content::NotificationObserver*>(manager()); |
| 434 observer->Observe(chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 434 observer->Observe(chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 435 content::Source<Profile>(profile()), | 435 content::Source<Profile>(profile()), |
| 436 content::Details<bool>(&is_fullscreen)); | 436 content::Details<bool>(&is_fullscreen)); |
| 437 EXPECT_FALSE(message_center()->HasPopupNotifications()); | 437 EXPECT_FALSE(message_center()->HasPopupNotifications()); |
| 438 } | 438 } |
| 439 | 439 |
| 440 #endif // !defined(OS_MACOSX) | 440 #endif // !defined(OS_MACOSX) |
| OLD | NEW |