From fad7ae54f7c12a9551badf1cb1f2620b5fa82504 Mon Sep 17 00:00:00 2001 From: robertshield Date: Mon, 5 Oct 2015 12:32:51 -0700 Subject: Prune metro bits from the ash tests BUG=332504 Review URL: https://codereview.chromium.org/1379683002 Cr-Commit-Position: refs/heads/master@{#352388} --- win8/BUILD.gn | 2 - win8/test/metro_registration_helper.cc | 132 --------------------------------- win8/test/metro_registration_helper.h | 23 ------ win8/win8.gyp | 2 - 4 files changed, 159 deletions(-) delete mode 100644 win8/test/metro_registration_helper.cc delete mode 100644 win8/test/metro_registration_helper.h (limited to 'win8') diff --git a/win8/BUILD.gn b/win8/BUILD.gn index d65f997..a064c15 100644 --- a/win8/BUILD.gn +++ b/win8/BUILD.gn @@ -34,8 +34,6 @@ source_set("test_support_win8") { configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] sources = [ - "test/metro_registration_helper.cc", - "test/metro_registration_helper.h", "test/open_with_dialog_async.cc", "test/open_with_dialog_async.h", "test/open_with_dialog_controller.cc", diff --git a/win8/test/metro_registration_helper.cc b/win8/test/metro_registration_helper.cc deleted file mode 100644 index 00f5b99..0000000 --- a/win8/test/metro_registration_helper.cc +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "win8/test/metro_registration_helper.h" - -#include - -#include - -#include "base/command_line.h" -#include "base/files/file_path.h" -#include "base/files/file_util.h" -#include "base/logging.h" -#include "base/path_service.h" -#include "base/process/kill.h" -#include "base/process/launch.h" -#include "base/process/process.h" -#include "base/strings/string16.h" -#include "base/win/scoped_co_mem.h" -#include "base/win/scoped_comptr.h" -#include "base/win/scoped_handle.h" -#include "win8/test/open_with_dialog_controller.h" -#include "win8/test/test_registrar_constants.h" - -namespace { - -const int kRegistrationTimeoutSeconds = 30; - -// Copied from util_constants.cc to avoid taking a dependency on installer_util. -const wchar_t kChromeExe[] = L"chrome.exe"; -const wchar_t kRegistrar[] = L"test_registrar.exe"; - -// Registers chrome.exe as a potential Win8 default browser. It will then show -// up in the default browser selection dialog as kDefaultTestExeName. Intended -// to be used by a test binary in the build output directory and assumes the -// presence of test_registrar.exe, a viewer process, and all needed DLLs in the -// same directory as the calling module. -bool RegisterTestDefaultBrowser() { - base::FilePath dir; - if (!PathService::Get(base::DIR_EXE, &dir)) - return false; - - base::FilePath chrome_exe(dir.Append(kChromeExe)); - base::FilePath registrar(dir.Append(kRegistrar)); - - if (!base::PathExists(chrome_exe) || !base::PathExists(registrar)) { - LOG(ERROR) << "Could not locate " << kChromeExe << " or " << kRegistrar; - return false; - } - - // Perform the registration by invoking test_registrar.exe. - base::CommandLine register_command(registrar); - register_command.AppendArg("/RegServer"); - - base::Process register_process = - base::LaunchProcess(register_command.GetCommandLineString(), - base::LaunchOptions()); - if (register_process.IsValid()) { - int ret = 0; - if (register_process.WaitForExitWithTimeout( - base::TimeDelta::FromSeconds(kRegistrationTimeoutSeconds), &ret)) { - if (ret == 0) { - return true; - } else { - LOG(ERROR) << "Win8 registration using " - << register_command.GetCommandLineString() - << " failed with error code " << ret; - } - } else { - LOG(ERROR) << "Win8 registration using " - << register_command.GetCommandLineString() << " timed out."; - } - } - - PLOG(ERROR) << "Failed to launch Win8 registration utility using " - << register_command.GetCommandLineString(); - return false; -} - -// Returns true if the test viewer's progid is the default handler for -// |protocol|. -bool IsTestDefaultForProtocol(const wchar_t* protocol) { - base::win::ScopedComPtr registration; - HRESULT hr = registration.CreateInstance( - CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); - if (FAILED(hr)) { - LOG(ERROR) << std::hex << hr; - return false; - } - - base::win::ScopedCoMem current_app; - hr = registration->QueryCurrentDefault(protocol, AT_URLPROTOCOL, - AL_EFFECTIVE, ¤t_app); - if (FAILED(hr)) { - LOG(ERROR) << std::hex << hr; - return false; - } - - return !base::string16(win8::test::kDefaultTestProgId).compare(current_app); -} - -} // namespace - -namespace win8 { - -bool MakeTestDefaultBrowserSynchronously() { - static const wchar_t kDefaultBrowserProtocol[] = L"http"; - - if (!RegisterTestDefaultBrowser()) - return false; - - // Make sure the registration changes have been acknowledged by the shell - // before querying for the current default. - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSH, NULL, NULL); - - // OpenWithDialogController will fail if the Test Runner is already default - // since it will not show up verbatim in the dialog (e.g., in EN-US, it will - // be prefixed by "Keep using "). - if (IsTestDefaultForProtocol(kDefaultBrowserProtocol)) - return true; - - std::vector choices; - OpenWithDialogController controller; - HRESULT hr = controller.RunSynchronously( - NULL, kDefaultBrowserProtocol, win8::test::kDefaultTestExeName, &choices); - LOG_IF(ERROR, FAILED(hr)) << std::hex << hr; - DCHECK(IsTestDefaultForProtocol(kDefaultBrowserProtocol)); - return SUCCEEDED(hr); -} - -} // namespace win8 diff --git a/win8/test/metro_registration_helper.h b/win8/test/metro_registration_helper.h deleted file mode 100644 index 58409db..0000000 --- a/win8/test/metro_registration_helper.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WIN8_TEST_METRO_REGISTRATION_HELPER_H_ -#define WIN8_TEST_METRO_REGISTRATION_HELPER_H_ - -#include "base/strings/string16.h" - -namespace win8 { - -// Synchronously makes chrome.exe THE default Win8 browser after which it is -// activatable into a Metro viewer process using -// win8::test::kDefaultTestAppUserModelId. Intended to be used by a test binary -// in the output directory and assumes the presence of test_registrar.exe, -// chrome.exe (the viewer process), and all needed DLLs in the same directory -// as the calling module. -// NOTE: COM must be initialized prior to calling this method. -bool MakeTestDefaultBrowserSynchronously(); - -} // namespace win8 - -#endif // WIN8_TEST_METRO_REGISTRATION_HELPER_H_ diff --git a/win8/win8.gyp b/win8/win8.gyp index e1fa5de..4c68624 100644 --- a/win8/win8.gyp +++ b/win8/win8.gyp @@ -46,8 +46,6 @@ 'test_registrar_constants', ], 'sources': [ - 'test/metro_registration_helper.cc', - 'test/metro_registration_helper.h', 'test/open_with_dialog_async.cc', 'test/open_with_dialog_async.h', 'test/open_with_dialog_controller.cc', -- cgit v1.1