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

Unified Diff: chrome/browser/extensions/tab_helper_unittest.cc

Issue 2037873002: [Extensions] Observe unloading extensions in the TabHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Istiaque's Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/tab_helper_unittest.cc
diff --git a/chrome/browser/extensions/tab_helper_unittest.cc b/chrome/browser/extensions/tab_helper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..175c222eff5a21b439cc7a9fe88af7e892619442
--- /dev/null
+++ b/chrome/browser/extensions/tab_helper_unittest.cc
@@ -0,0 +1,32 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/tab_helper.h"
+
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_service_test_with_install.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/test/web_contents_tester.h"
+
+namespace extensions {
+
+TEST_F(ExtensionServiceTestWithInstall, TabHelperClearsExtensionOnUnload) {
+ InitializeEmptyExtensionService();
+ const Extension* extension =
+ PackAndInstallCRX(data_dir().AppendASCII("hosted_app"), INSTALL_NEW);
+ ASSERT_TRUE(extension);
+ std::unique_ptr<content::WebContents> web_contents(
+ content::WebContentsTester::CreateTestWebContents(profile(), nullptr));
+ TabHelper::CreateForWebContents(web_contents.get());
+ TabHelper* tab_helper = TabHelper::FromWebContents(web_contents.get());
+ tab_helper->SetExtensionApp(extension);
+ EXPECT_EQ(extension, tab_helper->extension_app());
+ EXPECT_TRUE(tab_helper->is_app());
+ service()->UnloadExtension(extension->id(),
+ UnloadedExtensionInfo::REASON_UNDEFINED);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(nullptr, tab_helper->extension_app());
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698