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

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

Issue 7003100: Merge 88204 - Partially deprecate the old webstorePrivate.beginInstall method (Closed) Base URL: svn://svn.chromium.org/chrome/branches/782/src/
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
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/stringprintf.h" 5 #include "base/stringprintf.h"
6 #if defined (OS_WIN) 6 #if defined (OS_WIN)
7 #include "base/win/windows_version.h" 7 #include "base/win/windows_version.h"
8 #endif // defined (OS_WIN) 8 #endif // defined (OS_WIN)
9 9
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
11 #include "chrome/browser/extensions/extension_webstore_private_api.h" 11 #include "chrome/browser/extensions/extension_webstore_private_api.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/ui_test_utils.h" 13 #include "chrome/test/ui_test_utils.h"
14 #include "content/common/notification_observer.h"
15 #include "content/common/notification_registrar.h"
16 #include "content/common/notification_service.h"
17 #include "content/common/notification_type.h"
14 #include "net/base/mock_host_resolver.h" 18 #include "net/base/mock_host_resolver.h"
15 19
20 // This is a helper class to let us automatically accept extension install
21 // dialogs.
22 class GalleryInstallApiTestObserver :
23 public base::RefCounted<GalleryInstallApiTestObserver>,
24 public NotificationObserver {
25 public:
26 GalleryInstallApiTestObserver() {
27 registrar_.Add(this,
28 NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG,
29 NotificationService::AllSources());
30 }
31
32 void InstallUIProceed(ExtensionInstallUI::Delegate* delegate) {
33 delegate->InstallUIProceed();
34 }
35
36 virtual void Observe(NotificationType type,
37 const NotificationSource& source,
38 const NotificationDetails& details) OVERRIDE {
39 ExtensionInstallUI* prompt = Source<ExtensionInstallUI>(source).ptr();
40 CHECK(prompt->delegate_);
41 MessageLoop::current()->PostTask(
42 FROM_HERE, NewRunnableMethod(
43 this,
44 &GalleryInstallApiTestObserver::InstallUIProceed,
45 prompt->delegate_));
46 }
47
48 private:
49 NotificationRegistrar registrar_;
50 };
51
16 class ExtensionGalleryInstallApiTest : public ExtensionApiTest { 52 class ExtensionGalleryInstallApiTest : public ExtensionApiTest {
17 public: 53 public:
18 void SetUpCommandLine(CommandLine* command_line) { 54 void SetUpCommandLine(CommandLine* command_line) {
19 ExtensionApiTest::SetUpCommandLine(command_line); 55 ExtensionApiTest::SetUpCommandLine(command_line);
20 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, 56 command_line->AppendSwitchASCII(switches::kAppsGalleryURL,
21 "http://www.example.com"); 57 "http://www.example.com");
22 } 58 }
23 59
24 bool RunInstallTest(const std::string& page) { 60 bool RunInstallTest(const std::string& page) {
61 scoped_refptr<GalleryInstallApiTestObserver> observer =
62 new GalleryInstallApiTestObserver(); // Responds to install dialog.
25 std::string base_url = base::StringPrintf( 63 std::string base_url = base::StringPrintf(
26 "http://www.example.com:%u/files/extensions/", 64 "http://www.example.com:%u/files/extensions/",
27 test_server()->host_port_pair().port()); 65 test_server()->host_port_pair().port());
28 66
29 std::string testing_install_base_url = base_url; 67 std::string testing_install_base_url = base_url;
30 testing_install_base_url += "good.crx"; 68 testing_install_base_url += "good.crx";
31 69
32 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 70 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
33 switches::kAppsGalleryUpdateURL, testing_install_base_url); 71 switches::kAppsGalleryUpdateURL, testing_install_base_url);
34 72
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ASSERT_TRUE(RunInstallTest("test.html")); 114 ASSERT_TRUE(RunInstallTest("test.html"));
77 ASSERT_TRUE(RunInstallTest("complete_without_begin.html")); 115 ASSERT_TRUE(RunInstallTest("complete_without_begin.html"));
78 ASSERT_TRUE(RunInstallTest("invalid_begin.html")); 116 ASSERT_TRUE(RunInstallTest("invalid_begin.html"));
79 117
80 if (RunningOnXP()) { 118 if (RunningOnXP()) {
81 LOG(INFO) << "Starting tests with user gesture checking"; 119 LOG(INFO) << "Starting tests with user gesture checking";
82 } 120 }
83 BeginInstallFunction::SetIgnoreUserGestureForTests(false); 121 BeginInstallFunction::SetIgnoreUserGestureForTests(false);
84 ASSERT_TRUE(RunInstallTest("no_user_gesture.html")); 122 ASSERT_TRUE(RunInstallTest("no_user_gesture.html"));
85 } 123 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/crx_installer_browsertest.cc ('k') | chrome/browser/extensions/extension_install_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698