test: migrate shell specs to main process (#35058)

This commit is contained in:
Jeremy Rose 2022-07-27 09:18:33 -07:00 committed by GitHub
parent 99c2706376
commit de1cec8693
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 88 deletions

View file

@ -15,6 +15,7 @@
#include "shell/common/platform_util.h"
#if BUILDFLAG(IS_WIN)
#include "base/threading/thread_restrictions.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/shortcut.h"
@ -105,6 +106,11 @@ v8::Local<v8::Promise> TrashItem(v8::Isolate* isolate,
}
#if BUILDFLAG(IS_WIN)
// The use of the ForTesting flavors is a hack workaround to avoid having to
// patch these as friends into the associated guard classes.
class ShortcutAccessScopedAllowBlocking
: public base::ScopedAllowBlockingForTesting {};
bool WriteShortcutLink(const base::FilePath& shortcut_path,
gin_helper::Arguments* args) {
base::win::ShortcutOperation operation =
@ -136,6 +142,7 @@ bool WriteShortcutLink(const base::FilePath& shortcut_path,
if (options.Get("toastActivatorClsid", &toastActivatorClsid))
properties.set_toast_activator_clsid(toastActivatorClsid);
ShortcutAccessScopedAllowBlocking allow_blocking;
base::win::ScopedCOMInitializer com_initializer;
return base::win::CreateOrUpdateShortcutLink(shortcut_path, properties,
operation);
@ -145,6 +152,7 @@ v8::Local<v8::Value> ReadShortcutLink(gin_helper::ErrorThrower thrower,
const base::FilePath& path) {
using base::win::ShortcutProperties;
gin::Dictionary options = gin::Dictionary::CreateEmpty(thrower.isolate());
ShortcutAccessScopedAllowBlocking allow_blocking;
base::win::ScopedCOMInitializer com_initializer;
base::win::ShortcutProperties properties;
if (!base::win::ResolveShortcutProperties(