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

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: Requested changes made 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) 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/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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 #ifdef ADDRESS_SANITIZER 102 #ifdef ADDRESS_SANITIZER
101 // This test crashes under ASan, see http://crbug.com/100156 103 // This test crashes under ASan, see http://crbug.com/100156
102 #define MAYBE_ExtensionUninstall DISABLED_ExtensionUninstall 104 #define MAYBE_ExtensionUninstall DISABLED_ExtensionUninstall
103 #else 105 #else
104 #define MAYBE_ExtensionUninstall ExtensionUninstall 106 #define MAYBE_ExtensionUninstall ExtensionUninstall
105 #endif 107 #endif
106 TEST_F(AppNotificationManagerTest, MAYBE_ExtensionUninstall) { 108 TEST_F(AppNotificationManagerTest, MAYBE_ExtensionUninstall) {
107 // Add some items from two test extension ids. 109 // Add some items from two test extension ids.
108 std::string id1 = extension_test_util::MakeId("id1"); 110 scoped_refptr<Extension> extension1 =
109 std::string id2 = extension_test_util::MakeId("id2"); 111 extension_test_util::CreateExtensionWithID("id1");
112 scoped_refptr<Extension> extension2 =
113 extension_test_util::CreateExtensionWithID("id2");
114 std::string id1 = extension1->id();
115 std::string id2 = extension2->id();
110 AppNotificationList list1; 116 AppNotificationList list1;
111 AppNotificationList list2; 117 AppNotificationList list2;
112 util::AddNotifications(&list1, id1, 5, "foo1"); 118 util::AddNotifications(&list1, id1, 5, "foo1");
113 util::AddNotifications(&list2, id2, 3, "foo2"); 119 util::AddNotifications(&list2, id2, 3, "foo2");
114 util::AddCopiesFromList(mgr_.get(), list1); 120 util::AddCopiesFromList(mgr_.get(), list1);
115 util::AddCopiesFromList(mgr_.get(), list2); 121 util::AddCopiesFromList(mgr_.get(), list2);
116 util::ExpectListsEqual(list1, *mgr_->GetAll(id1)); 122 util::ExpectListsEqual(list1, *mgr_->GetAll(id1));
117 util::ExpectListsEqual(list2, *mgr_->GetAll(id2)); 123 util::ExpectListsEqual(list2, *mgr_->GetAll(id2));
118 124
119 // Send the uninstall notification for extension id1. 125 // Send the uninstall notification for extension id1.
120 content::NotificationService::current()->Notify( 126 content::NotificationService::current()->Notify(
121 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 127 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
122 content::Source<Profile>(profile_.get()), 128 content::Source<Profile>(profile_.get()),
123 content::Details<const std::string>(&id1)); 129 content::Details<const Extension>(extension1.get()));
124 130
125 // The id1 items should be gone but the id2 items should still be there. 131 // The id1 items should be gone but the id2 items should still be there.
126 EXPECT_EQ(NULL, mgr_->GetLast(id1)); 132 EXPECT_EQ(NULL, mgr_->GetLast(id1));
127 EXPECT_EQ(NULL, mgr_->GetAll(id1)); 133 EXPECT_EQ(NULL, mgr_->GetAll(id1));
128 util::ExpectListsEqual(list2, *mgr_->GetAll(id2)); 134 util::ExpectListsEqual(list2, *mgr_->GetAll(id2));
129 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698