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

Side by Side Diff: chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc

Issue 23981004: Synced Notifications Layout Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Layout Changes - fix unit tests Created 7 years, 3 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
« no previous file with comments | « chrome/browser/notifications/sync_notifier/synced_notification.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/notifications/notification.h" 10 #include "chrome/browser/notifications/notification.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 StubNotificationUIManager notification_manager; 320 StubNotificationUIManager notification_manager;
321 321
322 // Call the method under test using the pre-populated data. 322 // Call the method under test using the pre-populated data.
323 notification1_->Show(&notification_manager, NULL, NULL); 323 notification1_->Show(&notification_manager, NULL, NULL);
324 324
325 const Notification notification = notification_manager.notification(); 325 const Notification notification = notification_manager.notification();
326 326
327 // Check the base fields of the notification. 327 // Check the base fields of the notification.
328 EXPECT_EQ(message_center::NOTIFICATION_TYPE_IMAGE, notification.type()); 328 EXPECT_EQ(message_center::NOTIFICATION_TYPE_IMAGE, notification.type());
329 EXPECT_EQ(std::string(kTitle1), UTF16ToUTF8(notification.title())); 329 EXPECT_EQ(std::string(kTitle1), UTF16ToUTF8(notification.title()));
330 EXPECT_EQ(std::string(kText1And1), UTF16ToUTF8(notification.message())); 330 EXPECT_EQ(std::string(kText1), UTF16ToUTF8(notification.message()));
331 EXPECT_EQ(std::string(kExpectedOriginUrl), notification.origin_url().spec()); 331 EXPECT_EQ(std::string(kExpectedOriginUrl), notification.origin_url().spec());
332 EXPECT_EQ(std::string(kKey1), UTF16ToUTF8(notification.replace_id())); 332 EXPECT_EQ(std::string(kKey1), UTF16ToUTF8(notification.replace_id()));
333 333
334 EXPECT_EQ(kFakeCreationTime, notification.timestamp().ToDoubleT()); 334 EXPECT_EQ(kFakeCreationTime, notification.timestamp().ToDoubleT());
335 EXPECT_EQ(kNotificationPriority, notification.priority()); 335 EXPECT_EQ(kNotificationPriority, notification.priority());
336
337 EXPECT_EQ(UTF8ToUTF16(kContainedTitle1), notification.items()[0].title);
338 EXPECT_EQ(UTF8ToUTF16(kContainedTitle2), notification.items()[1].title);
339 EXPECT_EQ(UTF8ToUTF16(kContainedTitle3), notification.items()[2].title);
340
341 EXPECT_EQ(UTF8ToUTF16(kContainedMessage1), notification.items()[0].message);
342 EXPECT_EQ(UTF8ToUTF16(kContainedMessage2), notification.items()[1].message);
343 EXPECT_EQ(UTF8ToUTF16(kContainedMessage3), notification.items()[2].message);
344 } 336 }
345 337
346 TEST_F(SyncedNotificationTest, DismissTest) { 338 TEST_F(SyncedNotificationTest, DismissTest) {
347 339
348 if (!UseRichNotifications()) 340 if (!UseRichNotifications())
349 return; 341 return;
350 342
351 StubNotificationUIManager notification_manager; 343 StubNotificationUIManager notification_manager;
352 344
353 // Call the method under test using a dismissed notification. 345 // Call the method under test using a dismissed notification.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 391
400 // When we call OnFetchComplete on the second bitmap, show should be called. 392 // When we call OnFetchComplete on the second bitmap, show should be called.
401 notification1_->OnFetchComplete(GURL(kIconUrl2), &bitmap); 393 notification1_->OnFetchComplete(GURL(kIconUrl2), &bitmap);
402 EXPECT_EQ(0, notification1_->active_fetcher_count_); 394 EXPECT_EQ(0, notification1_->active_fetcher_count_);
403 395
404 // Since we check Show() thoroughly in its own test, we only check cursorily. 396 // Since we check Show() thoroughly in its own test, we only check cursorily.
405 EXPECT_EQ(message_center::NOTIFICATION_TYPE_IMAGE, 397 EXPECT_EQ(message_center::NOTIFICATION_TYPE_IMAGE,
406 notification_manager.notification().type()); 398 notification_manager.notification().type());
407 EXPECT_EQ(std::string(kTitle1), 399 EXPECT_EQ(std::string(kTitle1),
408 UTF16ToUTF8(notification_manager.notification().title())); 400 UTF16ToUTF8(notification_manager.notification().title()));
409 EXPECT_EQ(std::string(kText1And1), 401 EXPECT_EQ(std::string(kText1),
410 UTF16ToUTF8(notification_manager.notification().message())); 402 UTF16ToUTF8(notification_manager.notification().message()));
411 403
412 // TODO(petewil): Check that the bitmap in the notification is what we expect. 404 // TODO(petewil): Check that the bitmap in the notification is what we expect.
413 // This fails today, the type info is different. 405 // This fails today, the type info is different.
414 // EXPECT_TRUE(gfx::BitmapsAreEqual( 406 // EXPECT_TRUE(gfx::BitmapsAreEqual(
415 // image, notification1_->GetAppIconBitmap())); 407 // image, notification1_->GetAppIconBitmap()));
416 } 408 }
417 409
418 TEST_F(SyncedNotificationTest, QueueBitmapFetchJobsTest) { 410 TEST_F(SyncedNotificationTest, QueueBitmapFetchJobsTest) {
419 if (!UseRichNotifications()) 411 if (!UseRichNotifications())
420 return; 412 return;
421 413
422 StubNotificationUIManager notification_manager; 414 StubNotificationUIManager notification_manager;
423 415
424 notification1_->QueueBitmapFetchJobs(&notification_manager, NULL, NULL); 416 notification1_->QueueBitmapFetchJobs(&notification_manager, NULL, NULL);
425 417
426 // There should be 4 urls in the queue, icon, image, and two buttons. 418 // There should be 4 urls in the queue, icon, image, and two buttons.
427 EXPECT_EQ(4, notification1_->active_fetcher_count_); 419 EXPECT_EQ(4, notification1_->active_fetcher_count_);
428 } 420 }
429 421
430 // TODO(petewil): Add a test for a notification being read and or deleted. 422 // TODO(petewil): Add a test for a notification being read and or deleted.
431 423
432 } // namespace notifier 424 } // namespace notifier
OLDNEW
« no previous file with comments | « chrome/browser/notifications/sync_notifier/synced_notification.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698