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

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

Issue 10795090: Move ExecuteJavaScript functions from ui_test_utils.h to browser_test_utils.h so they can be reused… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "chrome/browser/extensions/autoupdate_interceptor.h" 7 #include "chrome/browser/extensions/autoupdate_interceptor.h"
8 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h" 11 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/extensions/updater/extension_updater.h" 12 #include "chrome/browser/extensions/updater/extension_updater.h"
13 #include "chrome/browser/infobars/infobar_tab_helper.h" 13 #include "chrome/browser/infobars/infobar_tab_helper.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/prefs/scoped_user_pref_update.h" 15 #include "chrome/browser/prefs/scoped_user_pref_update.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
19 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
22 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
25 #include "content/public/test/browser_test_utils.h"
25 #include "net/url_request/url_fetcher.h" 26 #include "net/url_request/url_fetcher.h"
26 27
27 using extensions::Extension; 28 using extensions::Extension;
28 29
29 class ExtensionManagementTest : public ExtensionBrowserTest { 30 class ExtensionManagementTest : public ExtensionBrowserTest {
30 protected: 31 protected:
31 // Helper method that returns whether the extension is at the given version. 32 // Helper method that returns whether the extension is at the given version.
32 // This calls version(), which must be defined in the extension's bg page, 33 // This calls version(), which must be defined in the extension's bg page,
33 // as well as asking the extension itself. 34 // as well as asking the extension itself.
34 // 35 //
35 // Note that 'version' here means something different than the version field 36 // Note that 'version' here means something different than the version field
36 // in the extension's manifest. We use the version as reported by the 37 // in the extension's manifest. We use the version as reported by the
37 // background page to test how overinstalling crx files with the same 38 // background page to test how overinstalling crx files with the same
38 // manifest version works. 39 // manifest version works.
39 bool IsExtensionAtVersion(const Extension* extension, 40 bool IsExtensionAtVersion(const Extension* extension,
40 const std::string& expected_version) { 41 const std::string& expected_version) {
41 // Test that the extension's version from the manifest and reported by the 42 // Test that the extension's version from the manifest and reported by the
42 // background page is correct. This is to ensure that the processes are in 43 // background page is correct. This is to ensure that the processes are in
43 // sync with the Extension. 44 // sync with the Extension.
44 ExtensionProcessManager* manager = browser()->profile()-> 45 ExtensionProcessManager* manager = browser()->profile()->
45 GetExtensionProcessManager(); 46 GetExtensionProcessManager();
46 ExtensionHost* ext_host = 47 ExtensionHost* ext_host =
47 manager->GetBackgroundHostForExtension(extension->id()); 48 manager->GetBackgroundHostForExtension(extension->id());
48 EXPECT_TRUE(ext_host); 49 EXPECT_TRUE(ext_host);
49 if (!ext_host) 50 if (!ext_host)
50 return false; 51 return false;
51 52
52 std::string version_from_bg; 53 std::string version_from_bg;
53 bool exec = ui_test_utils::ExecuteJavaScriptAndExtractString( 54 bool exec = content::ExecuteJavaScriptAndExtractString(
54 ext_host->render_view_host(), L"", L"version()", &version_from_bg); 55 ext_host->render_view_host(), L"", L"version()", &version_from_bg);
55 EXPECT_TRUE(exec); 56 EXPECT_TRUE(exec);
56 if (!exec) 57 if (!exec)
57 return false; 58 return false;
58 59
59 if (version_from_bg != expected_version || 60 if (version_from_bg != expected_version ||
60 extension->VersionString() != expected_version) 61 extension->VersionString() != expected_version)
61 return false; 62 return false;
62 return true; 63 return true;
63 } 64 }
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest")); 612 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest"));
612 } 613 }
613 ASSERT_TRUE(WaitForExtensionInstall()); 614 ASSERT_TRUE(WaitForExtensionInstall());
614 ASSERT_EQ(size_before + 1, service->extensions()->size()); 615 ASSERT_EQ(size_before + 1, service->extensions()->size());
615 extension = service->GetExtensionById(kExtensionId, false); 616 extension = service->GetExtensionById(kExtensionId, false);
616 ASSERT_TRUE(extension); 617 ASSERT_TRUE(extension);
617 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); 618 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location());
618 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 619 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
619 EXPECT_TRUE(service->disabled_extensions()->is_empty()); 620 EXPECT_TRUE(service->disabled_extensions()->is_empty());
620 } 621 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_keybinding_apitest.cc ('k') | chrome/browser/extensions/extension_nacl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698