Commit d2a3645c authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove using directives ("using namespace x") from chrome/browser/chromeos/.

Also other misc. cleanup, e.g. use make_unique more.

Bug: 82078
Change-Id: Ibe4384e74b905d4fc60392edf258663ddc6bc5a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1844339
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703234}
parent 6adb0722
......@@ -30,7 +30,7 @@
#include "ui/base/ime/chromeos/input_method_whitelist.h"
#include "ui/base/ime/ime_bridge.h"
using namespace chromeos::input_method;
using chromeos::input_method::InputMethodManager;
namespace {
......@@ -62,7 +62,8 @@ class TestListener : public content::NotificationObserver {
// background.
InputMethodManager* manager = InputMethodManager::Get();
manager->GetInputMethodUtil()->InitXkbInputMethodsForTesting(
*InputMethodWhitelist().GetSupportedInputMethods());
*chromeos::input_method::InputMethodWhitelist()
.GetSupportedInputMethods());
std::vector<std::string> keyboard_layouts;
keyboard_layouts.push_back(
......@@ -157,7 +158,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, ImeMenuAPITest) {
extension_ime_ids.push_back(kTestIMEID2);
InputMethodManager::Get()->GetActiveIMEState()->SetEnabledExtensionImes(
&extension_ime_ids);
InputMethodDescriptors extension_imes;
chromeos::input_method::InputMethodDescriptors extension_imes;
InputMethodManager::Get()->GetActiveIMEState()->GetInputMethodExtensions(
&extension_imes);
InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod(
......
......@@ -41,7 +41,6 @@
#include "extensions/browser/api_test_utils.h"
#include "extensions/browser/extension_function_dispatcher.h"
using namespace extensions;
namespace quick_unlock_private = extensions::api::quick_unlock_private;
using CredentialCheck = quick_unlock_private::CredentialCheck;
using CredentialProblem = quick_unlock_private::CredentialProblem;
......@@ -50,10 +49,6 @@ using QuickUnlockMode = quick_unlock_private::QuickUnlockMode;
using QuickUnlockModeList = std::vector<QuickUnlockMode>;
using CredentialList = std::vector<std::string>;
using ::testing::_;
using ::testing::Invoke;
using ::testing::WithArgs;
namespace chromeos {
namespace {
......@@ -132,7 +127,7 @@ enum ExpectedPinState {
} // namespace
class QuickUnlockPrivateUnitTest
: public ExtensionApiUnittest,
: public extensions::ExtensionApiUnittest,
public ::testing::WithParamInterface<TestType> {
public:
QuickUnlockPrivateUnitTest() = default;
......@@ -224,7 +219,7 @@ class QuickUnlockPrivateUnitTest
std::unique_ptr<quick_unlock_private::TokenInfo> GetAuthToken(
const std::string& password) {
// Setup a fake authenticator to avoid calling cryptohome methods.
auto* func = new QuickUnlockPrivateGetAuthTokenFunction();
auto* func = new extensions::QuickUnlockPrivateGetAuthTokenFunction();
func->SetAuthenticatorAllocatorForTesting(
base::Bind(&CreateFakeAuthenticator));
......@@ -241,7 +236,7 @@ class QuickUnlockPrivateUnitTest
// password. Expects the function to fail and returns the error.
std::string RunAuthTokenWithInvalidPassword() {
// Setup a fake authenticator to avoid calling cryptohome methods.
auto* func = new QuickUnlockPrivateGetAuthTokenFunction();
auto* func = new extensions::QuickUnlockPrivateGetAuthTokenFunction();
func->SetAuthenticatorAllocatorForTesting(
base::Bind(&CreateFakeAuthenticator));
......@@ -255,7 +250,8 @@ class QuickUnlockPrivateUnitTest
auto params = std::make_unique<base::ListValue>();
params->AppendString(token);
params->AppendBoolean(enabled);
RunFunction(new QuickUnlockPrivateSetLockScreenEnabledFunction(),
RunFunction(
new extensions::QuickUnlockPrivateSetLockScreenEnabledFunction(),
std::move(params));
}
......@@ -265,15 +261,15 @@ class QuickUnlockPrivateUnitTest
params->AppendString(kInvalidToken);
params->AppendBoolean(enabled);
return RunFunctionAndReturnError(
new QuickUnlockPrivateSetLockScreenEnabledFunction(),
new extensions::QuickUnlockPrivateSetLockScreenEnabledFunction(),
std::move(params));
}
// Wrapper for chrome.quickUnlockPrivate.getAvailableModes.
QuickUnlockModeList GetAvailableModes() {
// Run the function.
std::unique_ptr<base::Value> result =
RunFunction(new QuickUnlockPrivateGetAvailableModesFunction(),
std::unique_ptr<base::Value> result = RunFunction(
new extensions::QuickUnlockPrivateGetAvailableModesFunction(),
std::make_unique<base::ListValue>());
// Extract the results.
......@@ -293,7 +289,7 @@ class QuickUnlockPrivateUnitTest
// Wrapper for chrome.quickUnlockPrivate.getActiveModes.
QuickUnlockModeList GetActiveModes() {
std::unique_ptr<base::Value> result =
RunFunction(new QuickUnlockPrivateGetActiveModesFunction(),
RunFunction(new extensions::QuickUnlockPrivateGetActiveModesFunction(),
std::make_unique<base::ListValue>());
QuickUnlockModeList modes;
......@@ -344,8 +340,9 @@ class QuickUnlockPrivateUnitTest
params->AppendString(ToString(QuickUnlockMode::QUICK_UNLOCK_MODE_PIN));
params->AppendString(pin);
std::unique_ptr<base::Value> result = RunFunction(
new QuickUnlockPrivateCheckCredentialFunction(), std::move(params));
std::unique_ptr<base::Value> result =
RunFunction(new extensions::QuickUnlockPrivateCheckCredentialFunction(),
std::move(params));
CredentialCheck function_result;
EXPECT_TRUE(CredentialCheck::Populate(*result, &function_result));
......@@ -357,8 +354,8 @@ class QuickUnlockPrivateUnitTest
auto params = std::make_unique<base::ListValue>();
params->AppendString(ToString(QuickUnlockMode::QUICK_UNLOCK_MODE_PIN));
std::unique_ptr<base::Value> result =
RunFunction(new QuickUnlockPrivateGetCredentialRequirementsFunction(),
std::unique_ptr<base::Value> result = RunFunction(
new extensions::QuickUnlockPrivateGetCredentialRequirementsFunction(),
std::move(params));
CredentialRequirements function_result;
......@@ -394,7 +391,7 @@ class QuickUnlockPrivateUnitTest
const CredentialList& passwords) {
std::unique_ptr<base::ListValue> params =
GetSetModesParams(token_, modes, passwords);
auto* func = new QuickUnlockPrivateSetModesFunction();
auto* func = new extensions::QuickUnlockPrivateSetModesFunction();
// Stub out event handling since we are not setting up an event router.
func->SetModesChangedEventHandlerForTesting(modes_changed_handler_);
......@@ -414,7 +411,7 @@ class QuickUnlockPrivateUnitTest
std::string RunSetModesWithInvalidToken() {
std::unique_ptr<base::ListValue> params = GetSetModesParams(
kInvalidToken, {QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"111111"});
auto* func = new QuickUnlockPrivateSetModesFunction();
auto* func = new extensions::QuickUnlockPrivateSetModesFunction();
// Stub out event handling since we are not setting up an event router.
func->SetModesChangedEventHandlerForTesting(modes_changed_handler_);
......@@ -424,10 +421,11 @@ class QuickUnlockPrivateUnitTest
}
std::string SetModesWithError(const std::string& args) {
auto* func = new QuickUnlockPrivateSetModesFunction();
auto* func = new extensions::QuickUnlockPrivateSetModesFunction();
func->SetModesChangedEventHandlerForTesting(base::DoNothing());
return api_test_utils::RunFunctionAndReturnError(func, args, profile());
return extensions::api_test_utils::RunFunctionAndReturnError(func, args,
profile());
}
std::string token() { return token_; }
......@@ -474,11 +472,12 @@ class QuickUnlockPrivateUnitTest
scoped_refptr<ExtensionFunction> func,
std::unique_ptr<base::ListValue> params) {
base::RunLoop().RunUntilIdle();
std::unique_ptr<base::Value> result =
api_test_utils::RunFunctionWithDelegateAndReturnSingleResult(
std::unique_ptr<base::Value> result = extensions::api_test_utils::
RunFunctionWithDelegateAndReturnSingleResult(
func, std::move(params), profile(),
std::make_unique<ExtensionFunctionDispatcher>(profile()),
api_test_utils::NONE);
std::make_unique<extensions::ExtensionFunctionDispatcher>(
profile()),
extensions::api_test_utils::NONE);
base::RunLoop().RunUntilIdle();
return result;
}
......@@ -488,10 +487,11 @@ class QuickUnlockPrivateUnitTest
scoped_refptr<ExtensionFunction> func,
std::unique_ptr<base::ListValue> params) {
base::RunLoop().RunUntilIdle();
std::unique_ptr<ExtensionFunctionDispatcher> dispatcher(
new ExtensionFunctionDispatcher(profile()));
api_test_utils::RunFunction(func.get(), std::move(params), profile(),
std::move(dispatcher), api_test_utils::NONE);
auto dispatcher =
std::make_unique<extensions::ExtensionFunctionDispatcher>(profile());
extensions::api_test_utils::RunFunction(func.get(), std::move(params),
profile(), std::move(dispatcher),
extensions::api_test_utils::NONE);
EXPECT_TRUE(func->GetResultList()->empty());
base::RunLoop().RunUntilIdle();
return func->GetError();
......@@ -507,7 +507,7 @@ class QuickUnlockPrivateUnitTest
FakeChromeUserManager* fake_user_manager_ = nullptr;
std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_;
QuickUnlockPrivateSetModesFunction::ModesChangedEventHandler
extensions::QuickUnlockPrivateSetModesFunction::ModesChangedEventHandler
modes_changed_handler_;
bool expect_modes_changed_ = false;
chromeos::UserContext auth_token_user_context_;
......
......@@ -37,8 +37,6 @@
#include "ui/base/test/ui_controls.h"
#include "ui/views/widget/widget.h"
using namespace net::test_server;
namespace chromeos {
class OobeTest : public OobeBaseTest {
......
......@@ -116,12 +116,6 @@
namespace em = enterprise_management;
using net::test_server::BasicHttpResponse;
using net::test_server::HttpRequest;
using net::test_server::HttpResponse;
using testing::_;
using testing::Return;
namespace chromeos {
namespace {
......@@ -181,10 +175,11 @@ class FakeSamlIdp {
void SetCookieValue(const std::string& cookie_value);
void SetSamlResponseFile(const std::string& xml_file);
std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request);
std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
const net::test_server::HttpRequest& request);
private:
std::unique_ptr<HttpResponse> BuildHTMLResponse(
std::unique_ptr<net::test_server::HttpResponse> BuildHTMLResponse(
const std::string& html_template,
const std::string& relay_state,
const std::string& next_path);
......@@ -248,8 +243,8 @@ void FakeSamlIdp::SetCookieValue(const std::string& cookie_value) {
cookie_value_ = cookie_value;
}
std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest(
const HttpRequest& request) {
std::unique_ptr<net::test_server::HttpResponse> FakeSamlIdp::HandleRequest(
const net::test_server::HttpRequest& request) {
// The scheme and host of the URL is actually not important but required to
// get a valid GURL in order to parse |request.relative_url|.
GURL request_url = GURL("http://localhost").Resolve(request.relative_url);
......@@ -264,7 +259,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest(
if (request_path != login_auth_path_) {
// Request not understood.
return std::unique_ptr<HttpResponse>();
return nullptr;
}
std::string relay_state;
......@@ -281,7 +276,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest(
redirect_url =
net::AppendQueryParameter(redirect_url, kRelayState, relay_state);
std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse());
auto http_response = std::make_unique<net::test_server::BasicHttpResponse>();
http_response->set_code(net::HTTP_TEMPORARY_REDIRECT);
http_response->AddCustomHeader("Location", redirect_url.spec());
http_response->AddCustomHeader(
......@@ -289,7 +284,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest(
return std::move(http_response);
}
std::unique_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse(
std::unique_ptr<net::test_server::HttpResponse> FakeSamlIdp::BuildHTMLResponse(
const std::string& html_template,
const std::string& relay_state,
const std::string& next_path) {
......@@ -300,7 +295,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse(
base::ReplaceSubstringsAfterOffset(&response_html, 0, "$Refresh",
refresh_url_.spec());
std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse());
auto http_response = std::make_unique<net::test_server::BasicHttpResponse>();
http_response->set_code(net::HTTP_OK);
http_response->set_content(response_html);
http_response->set_content_type("text/html");
......@@ -866,9 +861,8 @@ void SAMLEnrollmentTest::StartSamlAndWaitForIdpPageLoad(
}
guest_view::TestGuestViewManager* SAMLEnrollmentTest::GetGuestViewManager() {
using namespace guest_view;
return static_cast<TestGuestViewManager*>(
TestGuestViewManager::FromBrowserContext(
return static_cast<guest_view::TestGuestViewManager*>(
guest_view::TestGuestViewManager::FromBrowserContext(
ProfileHelper::GetSigninProfile()));
}
......@@ -989,8 +983,8 @@ void SAMLPolicyTest::SetUpInProcessBrowserTestFixture() {
&test_helper_, device_affiliation_ids)));
// Initialize user policy.
EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
EXPECT_CALL(provider_, IsInitializationComplete(testing::_))
.WillRepeatedly(testing::Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
}
......
......@@ -25,8 +25,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/window.h"
using namespace testing;
namespace chromeos {
class UserAddingScreenTest : public LoginManagerTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment