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

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

Issue 8588067: Refactor to allow same code to test both sync and async functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix dependencies. Created 9 years, 1 month 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_function_test_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/extensions/extension_browsertest.h" 6 #include "chrome/browser/extensions/extension_browsertest.h"
7 #include "chrome/browser/extensions/extension_function_test_utils.h" 7 #include "chrome/browser/extensions/extension_function_test_utils.h"
8 #include "chrome/browser/extensions/extension_install_dialog.h" 8 #include "chrome/browser/extensions/extension_install_dialog.h"
9 #include "chrome/browser/extensions/extension_management_api.h" 9 #include "chrome/browser/extensions/extension_management_api.h"
10 #include "chrome/browser/extensions/extension_management_api_constants.h" 10 #include "chrome/browser/extensions/extension_management_api_constants.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 EXPECT_TRUE(service->GetExtensionById(kId, false) == NULL); 75 EXPECT_TRUE(service->GetExtensionById(kId, false) == NULL);
76 EXPECT_TRUE(service->GetExtensionById(kId, true) != NULL); 76 EXPECT_TRUE(service->GetExtensionById(kId, true) != NULL);
77 EXPECT_TRUE( 77 EXPECT_TRUE(
78 service->extension_prefs()->DidExtensionEscalatePermissions(kId)); 78 service->extension_prefs()->DidExtensionEscalatePermissions(kId));
79 } 79 }
80 80
81 void ReEnable(bool user_gesture, const std::string& expected_error) { 81 void ReEnable(bool user_gesture, const std::string& expected_error) {
82 scoped_refptr<SetEnabledFunction> function(new SetEnabledFunction); 82 scoped_refptr<SetEnabledFunction> function(new SetEnabledFunction);
83 if (user_gesture) 83 if (user_gesture)
84 function->set_user_gesture(true); 84 function->set_user_gesture(true);
85 bool response = util::RunAsyncFunction( 85 bool response = util::RunFunction(
86 function.get(), 86 function.get(),
87 base::StringPrintf("[\"%s\", true]", kId), 87 base::StringPrintf("[\"%s\", true]", kId),
88 browser(), 88 browser(),
89 util::NONE); 89 util::NONE);
90 if (expected_error.empty()) { 90 if (expected_error.empty()) {
91 EXPECT_EQ(true, response); 91 EXPECT_EQ(true, response);
92 } else { 92 } else {
93 EXPECT_TRUE(response == false); 93 EXPECT_TRUE(response == false);
94 EXPECT_EQ(expected_error, function->GetError()); 94 EXPECT_EQ(expected_error, function->GetError());
95 } 95 }
(...skipping 25 matching lines...) Expand all
121 ReEnable(false, keys::kGestureNeededForEscalationError); 121 ReEnable(false, keys::kGestureNeededForEscalationError);
122 122
123 // Expect an error that user cancelled the dialog. 123 // Expect an error that user cancelled the dialog.
124 SetExtensionInstallDialogAutoConfirmForTests(false); 124 SetExtensionInstallDialogAutoConfirmForTests(false);
125 ReEnable(true, keys::kUserDidNotReEnableError); 125 ReEnable(true, keys::kUserDidNotReEnableError);
126 126
127 // This should succeed when user accepts dialog. 127 // This should succeed when user accepts dialog.
128 SetExtensionInstallDialogAutoConfirmForTests(true); 128 SetExtensionInstallDialogAutoConfirmForTests(true);
129 ReEnable(true, ""); 129 ReEnable(true, "");
130 } 130 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698