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

Side by Side Diff: chrome/browser/extensions/app_notification_manager_sync_unittest.cc

Issue 8382010: Some fixups for app notifications: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "chrome/browser/extensions/app_notification_manager.h" 8 #include "chrome/browser/extensions/app_notification_manager.h"
9 #include "chrome/browser/extensions/app_notification.h" 9 #include "chrome/browser/extensions/app_notification.h"
10 #include "chrome/browser/sync/protocol/app_notification_specifics.pb.h" 10 #include "chrome/browser/sync/protocol/app_notification_specifics.pb.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 const std::string& link_text) { 139 const std::string& link_text) {
140 AppNotification* notif = new AppNotification( 140 AppNotification* notif = new AppNotification(
141 is_local, guid, extension_id, title, body); 141 is_local, guid, extension_id, title, body);
142 if (!link_url.empty()) 142 if (!link_url.empty())
143 notif->set_link_url(GURL(link_url)); 143 notif->set_link_url(GURL(link_url));
144 if (!link_text.empty()) 144 if (!link_text.empty())
145 notif->set_link_text(link_text); 145 notif->set_link_text(link_text);
146 return notif; 146 return notif;
147 } 147 }
148 148
149 static AppNotification* CreateNotification(const AppNotification& notif) {
150 return CreateNotification(
151 notif.is_local(), notif.guid(), notif.extension_id(), notif.title(),
152 notif.body(), notif.link_url().spec(), notif.link_text());
153 }
154
155 static SyncData CreateSyncData(int suffix) { 149 static SyncData CreateSyncData(int suffix) {
156 scoped_ptr<AppNotification> notif(CreateNotification(suffix)); 150 scoped_ptr<AppNotification> notif(CreateNotification(suffix));
157 return AppNotificationManager::CreateSyncDataFromNotification(*notif); 151 return AppNotificationManager::CreateSyncDataFromNotification(*notif);
158 } 152 }
159 static SyncData CreateSyncData(int suffix, const std::string& extension_id) { 153 static SyncData CreateSyncData(int suffix, const std::string& extension_id) {
160 scoped_ptr<AppNotification> notif( 154 scoped_ptr<AppNotification> notif(
161 CreateNotification(false, suffix, extension_id)); 155 CreateNotification(false, suffix, extension_id));
162 return AppNotificationManager::CreateSyncDataFromNotification(*notif); 156 return AppNotificationManager::CreateSyncDataFromNotification(*notif);
163 } 157 }
164 158
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 model()->Add(n2); 478 model()->Add(n2);
485 model()->MergeDataAndStartSyncing( 479 model()->MergeDataAndStartSyncing(
486 syncable::APP_NOTIFICATIONS, 480 syncable::APP_NOTIFICATIONS,
487 SyncDataList(), 481 SyncDataList(),
488 processor()); 482 processor());
489 483
490 // Some adds and some deletes. 484 // Some adds and some deletes.
491 SyncChangeList changes; 485 SyncChangeList changes;
492 changes.push_back(CreateSyncChange( 486 changes.push_back(CreateSyncChange(
493 SyncChange::ACTION_ADD, CreateNotification(3))); 487 SyncChange::ACTION_ADD, CreateNotification(3)));
494 changes.push_back(CreateSyncChange( 488 changes.push_back(CreateSyncChange(SyncChange::ACTION_DELETE, n1->Copy()));
495 SyncChange::ACTION_DELETE, CreateNotification(*n1)));
496 changes.push_back(CreateSyncChange( 489 changes.push_back(CreateSyncChange(
497 SyncChange::ACTION_ADD, CreateNotification(4))); 490 SyncChange::ACTION_ADD, CreateNotification(4)));
498 491
499 model()->ProcessSyncChanges(FROM_HERE, changes); 492 model()->ProcessSyncChanges(FROM_HERE, changes);
500 493
501 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::APP_NOTIFICATIONS).size()); 494 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::APP_NOTIFICATIONS).size());
502 EXPECT_EQ(2, processor()->change_list_size()); 495 EXPECT_EQ(2, processor()->change_list_size());
503 } 496 }
504 497
505 // Process sync changes should return error if model association is not done. 498 // Process sync changes should return error if model association is not done.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 572
580 EXPECT_EQ(3, processor()->change_list_size()); 573 EXPECT_EQ(3, processor()->change_list_size());
581 EXPECT_TRUE(processor()->ContainsGuid(n1->guid())); 574 EXPECT_TRUE(processor()->ContainsGuid(n1->guid()));
582 SyncChange c1 = processor()->GetChangeByGuid(n1->guid()); 575 SyncChange c1 = processor()->GetChangeByGuid(n1->guid());
583 AssertSyncChange(c1, SyncChange::ACTION_DELETE, *n1); 576 AssertSyncChange(c1, SyncChange::ACTION_DELETE, *n1);
584 SyncChange c2 = processor()->GetChangeByGuid(n2->guid()); 577 SyncChange c2 = processor()->GetChangeByGuid(n2->guid());
585 AssertSyncChange(c2, SyncChange::ACTION_DELETE, *n2); 578 AssertSyncChange(c2, SyncChange::ACTION_DELETE, *n2);
586 SyncChange c3 = processor()->GetChangeByGuid(n3->guid()); 579 SyncChange c3 = processor()->GetChangeByGuid(n3->guid());
587 AssertSyncChange(c3, SyncChange::ACTION_DELETE, *n3); 580 AssertSyncChange(c3, SyncChange::ACTION_DELETE, *n3);
588 } 581 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notification_manager.cc ('k') | chrome/browser/extensions/extension_app_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698