Commit ccec3fd0 authored by Michael Chang's avatar Michael Chang Committed by Commit Bot

Add test app to chrome/updater for end-to-end testing

Before integrating the new updater with Chromium src,
there needs to be end-to-end validation of the updater
features. Adding a simple test app will help in easily
determining this.

Bug: 1063435
Change-Id: I44d9ddaceec035be75158af5f6824c5410be0a0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2133169
Commit-Queue: Michael Chang <donchan@microsoft.com>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758355}
parent ebaac297
......@@ -204,6 +204,7 @@ if (is_win || is_mac) {
"//base",
"//base/test:test_support",
"//chrome/common:constants",
"//chrome/updater/test/test_app",
"//components/prefs:test_support",
"//components/update_client",
"//testing/gtest",
......
# Copyright 2020 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.
import("//build/config/mac/rules.gni")
import("//build/util/process_version.gni")
import("//build/util/version.gni")
import("//chrome/updater/branding.gni")
app_name = "UpdaterTestApp"
app_bundle_id = "org.chromium.updatertestapp"
if (is_mac) {
app_framework_name = app_name + " Framework"
}
group("test_app") {
deps = [ ":app" ]
}
process_version("version_header") {
sources = [ "//chrome/VERSION" ]
extra_args = [
"-e",
"TEST_APP_FULLNAME=\"$app_name\"",
"-e",
"TEST_APP_BUNDLE_IDENTIFIER=\"$app_bundle_id\"",
"-e",
"UPDATER_APP_FULLNAME=\"$updater_product_full_name\"",
]
template_file = "test_app_version.h.in"
output = "$target_gen_dir/test_app_version.h"
}
source_set("app_sources") {
sources = [
"//chrome/updater/util.cc",
"//chrome/updater/util.h",
"constants.cc",
"constants.h",
"test_app.cc",
"test_app.h",
"test_app_mac.mm",
"test_app_win.cc",
]
deps = [
":version_header",
"//base",
"//chrome/updater:version_header",
]
if (is_mac) {
deps += [ "//chrome/updater/mac:xpc_names" ]
libs = [ "CoreFoundation.framework" ]
}
}
if (is_win) {
executable("app") {
output_name = "updatertestapp"
sources = [ "main_win.cc" ]
configs += [ "//build/config/win:windowed" ]
deps = [ ":app_sources" ]
}
}
if (is_mac) {
mac_app_bundle("app") {
info_plist = "mac/Info.plist"
output_name = app_name
extra_substitutions = [ "MAC_BUNDLE_IDENTIFIER=$app_bundle_id" ]
sources = [ "main_mac.cc" ]
deps = [
":app_sources",
":bundle_versioned_data",
":version_header",
"//base",
]
}
bundle_data("bundle_versioned_data") {
sources = [ "$root_out_dir/$app_framework_name.framework" ]
outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
public_deps = [ ":app_framework" ]
}
bundle_data("bundle_updater") {
sources = [ "$root_out_dir/$updater_product_full_name.app" ]
outputs = [ "{{bundle_contents_dir}}/Helpers/{{source_file_part}}" ]
public_deps = [ "//chrome/updater/mac:updater_bundle" ]
}
mac_framework_bundle("app_framework") {
output_name = app_framework_name
framework_version = chrome_version_full
framework_contents = [
"Helpers",
"Resources",
]
info_plist = "mac/framework-Info.plist"
extra_substitutions = [ "CHROMIUM_BUNDLE_ID=$app_bundle_id" ]
deps = [ ":bundle_updater" ]
ldflags = [ "-Wl,-install_name,@executable_path/../Frameworks/$app_framework_name.framework/Versions/$chrome_version_full/$app_framework_name" ]
ldflags += [
"-compatibility_version",
chrome_dylib_version,
"-current_version",
chrome_dylib_version,
]
}
}
// Copyright 2020 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 "chrome/updater/test/test_app/constants.h"
namespace updater {
const char kInstallUpdaterSwitch[] = "install-updater";
const char kRegisterToUpdaterSwitch[] = "ipc-register";
const char kForegroundUpdateSwitch[] = "ipc-update";
} // namespace updater
// Copyright 2020 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 CHROME_UPDATER_TEST_TEST_APP_CONSTANTS_H_
#define CHROME_UPDATER_TEST_TEST_APP_CONSTANTS_H_
namespace updater {
// Installs the updater.
extern const char kInstallUpdaterSwitch[];
// Registers the test app to the updater through IPC.
extern const char kRegisterToUpdaterSwitch[];
// Initiates a foreground update through IPC.
extern const char kForegroundUpdateSwitch[];
} // namespace updater
#endif // CHROME_UPDATER_TEST_TEST_APP_CONSTANTS_H_
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleIdentifier</key>
<string>${MAC_BUNDLE_IDENTIFIER}</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${CHROMIUM_BUNDLE_ID}.framework</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
</dict>
</plist>
// Copyright 2020 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 "chrome/updater/test/test_app/test_app.h"
int main(int argc, const char* argv[]) {
return updater::TestAppMain(argc, argv);
}
// Copyright 2020 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 <windows.h>
#include "chrome/updater/test/test_app/test_app.h"
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) {
return updater::TestAppMain(0, nullptr);
}
// Copyright 2020 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 "chrome/updater/test/test_app/test_app.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "chrome/updater/test/test_app/constants.h"
#include "chrome/updater/util.h"
namespace updater {
namespace {
int ParseCommandLine(const base::CommandLine* command_line) {
if (command_line->HasSwitch(kInstallUpdaterSwitch))
InstallUpdater();
if (command_line->HasSwitch(kRegisterToUpdaterSwitch))
RegisterToUpdater();
if (command_line->HasSwitch(kForegroundUpdateSwitch))
DoForegroundUpdate();
return 0;
}
} // namespace
int TestAppMain(int argc, const char** argv) {
base::CommandLine::Init(argc, argv);
updater::InitLogging(FILE_PATH_LITERAL("test_app.log"));
return ParseCommandLine(base::CommandLine::ForCurrentProcess());
}
} // namespace updater
// Copyright 2020 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 CHROME_UPDATER_TEST_TEST_APP_TEST_APP_H_
#define CHROME_UPDATER_TEST_TEST_APP_TEST_APP_H_
namespace updater {
// Initiates a foreground update through IPC.
void DoForegroundUpdate();
// Installs the updater.
void InstallUpdater();
// Registers the test app to the updater through IPC.
void RegisterToUpdater();
int TestAppMain(int argc, const char** argv);
} // namespace updater
#endif // CHROME_UPDATER_TEST_TEST_APP_TEST_APP_H_
// Copyright 2020 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 "chrome/updater/test/test_app/test_app.h"
#import <Cocoa/Cocoa.h>
#include <string>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/bundle_locations.h"
#import "base/mac/foundation_util.h"
#include "base/process/launch.h"
#include "chrome/updater/mac/xpc_service_names.h"
#include "chrome/updater/test/test_app/constants.h"
#include "chrome/updater/test/test_app/test_app_version.h"
namespace updater {
namespace {
constexpr char kInstallCommand[] = "install";
base::FilePath GetUpdaterAppName() {
return base::FilePath(UPDATER_APP_FULLNAME_STRING ".app");
}
base::FilePath GetTestAppFrameworkName() {
return base::FilePath(TEST_APP_FULLNAME_STRING " Framework.framework");
}
} // namespace
void DoForegroundUpdate() {
// TODO(1068693): Implement TestApp Functionality
NOTIMPLEMENTED();
}
void InstallUpdater() {
// The updater executable is in
// C.app/Contents/Frameworks/C.framework/Versions/V/Helpers/CUpdater.app
base::FilePath updater_executable_path =
base::mac::OuterBundlePath()
.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("Frameworks"))
.Append(FILE_PATH_LITERAL(GetTestAppFrameworkName()))
.Append(FILE_PATH_LITERAL("Versions"))
.Append(FILE_PATH_LITERAL(TEST_APP_VERSION_STRING))
.Append(FILE_PATH_LITERAL("Helpers"))
.Append(GetUpdaterAppName())
.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("MacOS"))
.Append(FILE_PATH_LITERAL(UPDATER_APP_FULLNAME_STRING));
if (!base::PathExists(updater_executable_path)) {
LOG(ERROR) << "Path to the updater app does not exist!";
return;
}
base::CommandLine command(updater_executable_path);
command.AppendSwitch(kInstallCommand);
std::string output;
int exit_code = 0;
base::GetAppOutputWithExitCode(command, &output, &exit_code);
if (exit_code != 0)
LOG(ERROR) << "Couldn't install the updater. Exit code: " << exit_code;
}
void RegisterToUpdater() {
// TODO(1068693): Implement TestApp Functionality
NOTIMPLEMENTED();
}
} // namespace updater
// Copyright 2020 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.
// Version Information
#define TEST_APP_VERSION @MAJOR@,@MINOR@,@BUILD@,@PATCH@
#define TEST_APP_VERSION_STRING "@MAJOR@.@MINOR@.@BUILD@.@PATCH@"
// Branding Information
#define TEST_APP_FULLNAME_STRING "@TEST_APP_FULLNAME@"
#define TEST_APP_MAC_BUNDLE_IDENTIFIER_STRING "@TEST_APP_BUNDLE_IDENTIFIER@"
#define UPDATER_APP_FULLNAME_STRING "@UPDATER_APP_FULLNAME@"
// Copyright 2020 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 "chrome/updater/test/test_app/test_app.h"
#include "base/logging.h"
namespace updater {
void DoForegroundUpdate() {
// TODO(1068693): Implement TestApp Functionality
NOTIMPLEMENTED();
}
void InstallUpdater() {
// TODO(1068693): Implement TestApp Functionality
NOTIMPLEMENTED();
}
void RegisterToUpdater() {
// TODO(1068693): Implement TestApp Functionality
NOTIMPLEMENTED();
}
} // namespace updater
......@@ -5,7 +5,6 @@
#include "chrome/updater/util.h"
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
......@@ -40,4 +39,20 @@ bool GetProductDirectory(base::FilePath* path) {
return true;
}
// The log file is created in DIR_LOCAL_APP_DATA or DIR_APP_DATA.
void InitLogging(const base::FilePath::StringType& filename) {
logging::LoggingSettings settings;
base::FilePath log_dir;
GetProductDirectory(&log_dir);
const base::FilePath log_file = log_dir.Append(filename);
settings.log_file_path = log_file.value().c_str();
settings.logging_dest = logging::LOG_TO_ALL;
logging::InitLogging(settings);
logging::SetLogItems(/*enable_process_id=*/true,
/*enable_thread_id=*/true,
/*enable_timestamp=*/true,
/*enable_tickcount=*/false);
VLOG(1) << "Log file: " << settings.log_file_path;
}
} // namespace updater
......@@ -5,15 +5,16 @@
#ifndef CHROME_UPDATER_UTIL_H_
#define CHROME_UPDATER_UTIL_H_
namespace base {
class FilePath;
}
#include "base/files/file_path.h"
namespace updater {
// Returns a directory where updater files or its data is stored.
bool GetProductDirectory(base::FilePath* path);
// Initializes logging for an executable.
void InitLogging(const base::FilePath::StringType& filename);
} // namespace updater
#endif // CHROME_UPDATER_UTIL_H_
......@@ -1403,7 +1403,8 @@ class MetaBuildWrapper(object):
# Skip a few existing violations that need to be cleaned up. Each of
# these will lead to incorrect incremental builds if their directory
# contents change. Do not add to this list.
# contents change. Do not add to this list, except for mac bundles until
# crbug.com/1000667 is fixed.
# TODO(https://crbug.com/912946): Remove this if statement.
if ((is_msan and f == 'instrumented_libraries_prebuilt/')
or f == 'mr_extension/' or # https://crbug.com/997947
......@@ -1436,6 +1437,8 @@ class MetaBuildWrapper(object):
'Google Chrome Helper.app/',
'Google Chrome.app/',
'GoogleUpdater.app/',
'UpdaterTestApp Framework.framework/',
'UpdaterTestApp.app/',
'blink_deprecated_test_plugin.plugin/',
'blink_test_plugin.plugin/',
'corb_test_plugin.plugin/',
......
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