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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h"
7 #include "base/run_loop.h"
8 #include "chrome/browser/extensions/extension_install_prompt.h"
9 #include "content/public/test/test_browser_thread_bundle.h"
10 #include "extensions/common/extension.h"
11 #include "extensions/common/extension_builder.h"
12 #include "extensions/common/permissions/api_permission.h"
13 #include "extensions/common/permissions/api_permission_set.h"
14 #include "extensions/common/permissions/manifest_permission_set.h"
15 #include "extensions/common/permissions/permission_set.h"
16 #include "extensions/common/url_pattern_set.h"
17 #include "extensions/common/value_builder.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19
20 namespace extensions {
21
22 void VerifyPromptPermissionsCallback(
23 const base::Closure& quit_closure,
24 const ExtensionInstallPrompt::ShowParams& params,
25 ExtensionInstallPrompt::Delegate* delegate,
26 scoped_refptr<ExtensionInstallPrompt::Prompt> install_prompt) {
27 ASSERT_TRUE(install_prompt.get());
28 EXPECT_EQ(1u, install_prompt->GetPermissionCount());
29 quit_closure.Run();
30 }
31
32 TEST(ExtensionInstallPromptUnittest, PromptShowsPermissionWarnings) {
33 content::TestBrowserThreadBundle thread_bundle;
34 APIPermissionSet api_permissions;
35 api_permissions.insert(APIPermission::kTab);
36 scoped_refptr<PermissionSet> permission_set =
37 new PermissionSet(api_permissions,
38 ManifestPermissionSet(),
39 URLPatternSet(),
40 URLPatternSet());
41 scoped_refptr<const Extension> extension =
42 ExtensionBuilder().SetManifest(
43 DictionaryBuilder().Set("name", "foo")
44 .Set("version", "1.0")
45 .Set("manifest_version", 2)
46 .Set("description", "Random Ext")).Build();
47 ExtensionInstallPrompt prompt(NULL /* no web contents in this test */);
48 base::RunLoop run_loop;
49 prompt.set_callback_for_test(base::Bind(&VerifyPromptPermissionsCallback,
50 run_loop.QuitClosure()));
51 prompt.ConfirmPermissions(NULL, // no delegate
52 extension,
53 permission_set);
54 run_loop.Run();
55 }
56
57 } // namespace extensions
OLDNEW
« 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