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

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

Issue 7131001: Partially deprecate the old webstorePrivate.beginInstall method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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
16 class ExtensionGalleryInstallApiTest : public ExtensionApiTest { 20 class ExtensionGalleryInstallApiTest : public ExtensionApiTest {
17 public: 21 public:
18 void SetUpCommandLine(CommandLine* command_line) { 22 void SetUpCommandLine(CommandLine* command_line) {
19 ExtensionApiTest::SetUpCommandLine(command_line); 23 ExtensionApiTest::SetUpCommandLine(command_line);
20 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, 24 command_line->AppendSwitchASCII(switches::kAppsGalleryURL,
21 "http://www.example.com"); 25 "http://www.example.com");
22 } 26 }
23 27
24 bool RunInstallTest(const std::string& page) { 28 bool RunInstallTest(const std::string& page) {
29 NotificationRegistrar registrar;
30 registrar.Add(this,
31 NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG,
32 NotificationService::AllSources());
25 std::string base_url = base::StringPrintf( 33 std::string base_url = base::StringPrintf(
26 "http://www.example.com:%u/files/extensions/", 34 "http://www.example.com:%u/files/extensions/",
27 test_server()->host_port_pair().port()); 35 test_server()->host_port_pair().port());
28 36
29 std::string testing_install_base_url = base_url; 37 std::string testing_install_base_url = base_url;
30 testing_install_base_url += "good.crx"; 38 testing_install_base_url += "good.crx";
31 39
32 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 40 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
33 switches::kAppsGalleryUpdateURL, testing_install_base_url); 41 switches::kAppsGalleryUpdateURL, testing_install_base_url);
34 42
35 std::string page_url = base_url; 43 std::string page_url = base_url;
36 page_url += "api_test/extension_gallery_install/" + page; 44 page_url += "api_test/extension_gallery_install/" + page;
37 45
38 return RunPageTest(page_url.c_str()); 46 return RunPageTest(page_url.c_str());
39 } 47 }
48
49 void InstallUIProceed(ExtensionInstallUI::Delegate* delegate) {
50 delegate->InstallUIProceed();
51 }
52
53 // We implement the NotificationObserver interface to drive the install
54 // dialog.
55 virtual void Observe(NotificationType type,
Matt Perry 2011/06/07 18:03:30 Don't you need to call the parent class' Observe?
56 const NotificationSource& source,
57 const NotificationDetails& details) OVERRIDE {
58 ExtensionInstallUI* prompt = Source<ExtensionInstallUI>(source).ptr();
59 CHECK(prompt->delegate_);
60 MessageLoop::current()->PostTask(
61 FROM_HERE, NewRunnableMethod(
62 this,
63 &ExtensionGalleryInstallApiTest::InstallUIProceed,
64 prompt->delegate_));
65 }
40 }; 66 };
41 67
42 namespace { 68 namespace {
43 69
44 bool RunningOnXP() { 70 bool RunningOnXP() {
45 #if defined (OS_WIN) 71 #if defined (OS_WIN)
46 return GetVersion() < base::win::VERSION_VISTA; 72 return GetVersion() < base::win::VERSION_VISTA;
47 #else 73 #else
48 return false; 74 return false;
49 #endif // defined (OS_WIN) 75 #endif // defined (OS_WIN)
(...skipping 26 matching lines...) Expand all
76 ASSERT_TRUE(RunInstallTest("test.html")); 102 ASSERT_TRUE(RunInstallTest("test.html"));
77 ASSERT_TRUE(RunInstallTest("complete_without_begin.html")); 103 ASSERT_TRUE(RunInstallTest("complete_without_begin.html"));
78 ASSERT_TRUE(RunInstallTest("invalid_begin.html")); 104 ASSERT_TRUE(RunInstallTest("invalid_begin.html"));
79 105
80 if (RunningOnXP()) { 106 if (RunningOnXP()) {
81 LOG(INFO) << "Starting tests with user gesture checking"; 107 LOG(INFO) << "Starting tests with user gesture checking";
82 } 108 }
83 BeginInstallFunction::SetIgnoreUserGestureForTests(false); 109 BeginInstallFunction::SetIgnoreUserGestureForTests(false);
84 ASSERT_TRUE(RunInstallTest("no_user_gesture.html")); 110 ASSERT_TRUE(RunInstallTest("no_user_gesture.html"));
85 } 111 }
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