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

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

Issue 10694056: CPM Extension Uninstall Watching (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 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
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/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "chrome/browser/extensions/app_notification_manager.h" 7 #include "chrome/browser/extensions/app_notification_manager.h"
8 #include "chrome/browser/extensions/app_notification_test_util.h" 8 #include "chrome/browser/extensions/app_notification_test_util.h"
9 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_manifest_constants.h"
11 #include "chrome/common/extensions/extension_test_util.h" 12 #include "chrome/common/extensions/extension_test_util.h"
12 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
13 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
16 #include "content/public/test/test_browser_thread.h" 17 #include "content/public/test/test_browser_thread.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using content::BrowserThread; 20 using content::BrowserThread;
21 using extensions::Extension;
20 22
21 namespace util = app_notification_test_util; 23 namespace util = app_notification_test_util;
22 24
23 class AppNotificationManagerTest : public testing::Test { 25 class AppNotificationManagerTest : public testing::Test {
24 public: 26 public:
25 AppNotificationManagerTest() 27 AppNotificationManagerTest()
26 : ui_thread_(BrowserThread::UI, &ui_loop_), 28 : ui_thread_(BrowserThread::UI, &ui_loop_),
27 file_thread_(BrowserThread::FILE) {} 29 file_thread_(BrowserThread::FILE) {}
28 30
29 ~AppNotificationManagerTest() {} 31 ~AppNotificationManagerTest() {}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 util::ExpectListsEqual(list, *tmp_list); 94 util::ExpectListsEqual(list, *tmp_list);
93 mgr_->ClearAll(id); 95 mgr_->ClearAll(id);
94 EXPECT_EQ(NULL, mgr_->GetLast(id)); 96 EXPECT_EQ(NULL, mgr_->GetLast(id));
95 EXPECT_EQ(NULL, mgr_->GetAll(id)); 97 EXPECT_EQ(NULL, mgr_->GetAll(id));
96 } 98 }
97 99
98 // Test that AppNotificationManager correctly listens to EXTENSION_UNINSTALLED 100 // Test that AppNotificationManager correctly listens to EXTENSION_UNINSTALLED
99 // notifications and removes associated data when that happens. 101 // notifications and removes associated data when that happens.
100 TEST_F(AppNotificationManagerTest, ExtensionUninstall) { 102 TEST_F(AppNotificationManagerTest, ExtensionUninstall) {
101 // Add some items from two test extension ids. 103 // Add some items from two test extension ids.
102 std::string id1 = extension_test_util::MakeId("id1"); 104 scoped_refptr<Extension> extension1 =
103 std::string id2 = extension_test_util::MakeId("id2"); 105 extension_test_util::CreateExtensionWithID("id1");
106 scoped_refptr<Extension> extension2 =
107 extension_test_util::CreateExtensionWithID("id2");
108 std::string id1 = extension1->id();
109 std::string id2 = extension2->id();
104 AppNotificationList list1; 110 AppNotificationList list1;
105 AppNotificationList list2; 111 AppNotificationList list2;
106 util::AddNotifications(&list1, id1, 5, "foo1"); 112 util::AddNotifications(&list1, id1, 5, "foo1");
107 util::AddNotifications(&list2, id2, 3, "foo2"); 113 util::AddNotifications(&list2, id2, 3, "foo2");
108 util::AddCopiesFromList(mgr_.get(), list1); 114 util::AddCopiesFromList(mgr_.get(), list1);
109 util::AddCopiesFromList(mgr_.get(), list2); 115 util::AddCopiesFromList(mgr_.get(), list2);
110 util::ExpectListsEqual(list1, *mgr_->GetAll(id1)); 116 util::ExpectListsEqual(list1, *mgr_->GetAll(id1));
111 util::ExpectListsEqual(list2, *mgr_->GetAll(id2)); 117 util::ExpectListsEqual(list2, *mgr_->GetAll(id2));
112 118
113 // Send the uninstall notification for extension id1. 119 // Send the uninstall notification for extension id1.
114 content::NotificationService::current()->Notify( 120 content::NotificationService::current()->Notify(
115 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 121 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
116 content::Source<Profile>(profile_.get()), 122 content::Source<Profile>(profile_.get()),
117 content::Details<const std::string>(&id1)); 123 content::Details<const Extension>(extension1.get()));
118 124
119 // The id1 items should be gone but the id2 items should still be there. 125 // The id1 items should be gone but the id2 items should still be there.
120 EXPECT_EQ(NULL, mgr_->GetLast(id1)); 126 EXPECT_EQ(NULL, mgr_->GetLast(id1));
121 EXPECT_EQ(NULL, mgr_->GetAll(id1)); 127 EXPECT_EQ(NULL, mgr_->GetAll(id1));
122 util::ExpectListsEqual(list2, *mgr_->GetAll(id2)); 128 util::ExpectListsEqual(list2, *mgr_->GetAll(id2));
123 } 129 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notification_manager.cc ('k') | chrome/browser/extensions/app_shortcut_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698