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

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

Issue 448883002: Fix permission regression where warnings aren't shown in the dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/extension_install_prompt.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/extension_install_prompt_unittest.cc
diff --git a/chrome/browser/extensions/extension_install_prompt_unittest.cc b/chrome/browser/extensions/extension_install_prompt_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..347db0f03426e0cfec2075e19c850f3bfca4e236
--- /dev/null
+++ b/chrome/browser/extensions/extension_install_prompt_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright 2014 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 "base/bind.h"
+#include "base/memory/ref_counted.h"
+#include "base/run_loop.h"
+#include "chrome/browser/extensions/extension_install_prompt.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_builder.h"
+#include "extensions/common/permissions/api_permission.h"
+#include "extensions/common/permissions/api_permission_set.h"
+#include "extensions/common/permissions/manifest_permission_set.h"
+#include "extensions/common/permissions/permission_set.h"
+#include "extensions/common/url_pattern_set.h"
+#include "extensions/common/value_builder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+
+void VerifyPromptPermissionsCallback(
+ const base::Closure& quit_closure,
+ const ExtensionInstallPrompt::ShowParams& params,
+ ExtensionInstallPrompt::Delegate* delegate,
+ scoped_refptr<ExtensionInstallPrompt::Prompt> install_prompt) {
+ ASSERT_TRUE(install_prompt.get());
+ EXPECT_EQ(1u, install_prompt->GetPermissionCount());
+ quit_closure.Run();
+}
+
+TEST(ExtensionInstallPromptUnittest, PromptShowsPermissionWarnings) {
+ content::TestBrowserThreadBundle thread_bundle;
+ APIPermissionSet api_permissions;
+ api_permissions.insert(APIPermission::kTab);
+ scoped_refptr<PermissionSet> permission_set =
+ new PermissionSet(api_permissions,
+ ManifestPermissionSet(),
+ URLPatternSet(),
+ URLPatternSet());
+ scoped_refptr<const Extension> extension =
+ ExtensionBuilder().SetManifest(
+ DictionaryBuilder().Set("name", "foo")
+ .Set("version", "1.0")
+ .Set("manifest_version", 2)
+ .Set("description", "Random Ext")).Build();
+ ExtensionInstallPrompt prompt(NULL /* no web contents in this test */);
+ base::RunLoop run_loop;
+ prompt.set_callback_for_test(base::Bind(&VerifyPromptPermissionsCallback,
+ run_loop.QuitClosure()));
+ prompt.ConfirmPermissions(NULL, // no delegate
+ extension,
+ permission_set);
+ run_loop.Run();
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698