Commit c39dc317 authored by Findit's avatar Findit

Revert "CrOS FilesApp: refactor strings to allow reuse in tests"

This reverts commit e7492cbb.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 589442 as the
culprit for failures in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtL2U3NDkyY2JiM2M4N2MxNWE3YTE3YjlkMjI4YTcyNmE4ZTYxNTEzMWEM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.memory/Linux%20Chromium%20OS%20ASan%20LSan%20Builder/40795

Sample Failed Step: compile

Original change's description:
> CrOS FilesApp: refactor strings to allow reuse in tests
> 
> Created static FileManagerPrivateStrings::GetStrings() which is called
> by fileManagerPrivate.getStrings() extension function, and can now also
> be called by utility executable to generate strings.js file for
> testing rather than having strings duplicated.
> 
> Bug: 813477
> Change-Id: Ife2ac1b018660451a8c32180e5260f1d9fb6baf2
> Reviewed-on: https://chromium-review.googlesource.com/1208993
> Commit-Queue: Joel Hockey <joelhockey@chromium.org>
> Reviewed-by: Luciano Pacheco <lucmult@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#589442}

Change-Id: I4b29ee18d2a663e08108aaf796bcae2aa0728d9a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 813477
Reviewed-on: https://chromium-review.googlesource.com/1212486
Cr-Commit-Position: refs/heads/master@{#589450}
parent 799e7f9f
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/extensions/file_manager/private_api_strings.h" #include "chrome/browser/chromeos/extensions/file_manager/private_api_strings.h"
#include <memory>
#include <utility> #include <utility>
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
...@@ -404,7 +405,31 @@ void AddStringsForZipArchiver(base::DictionaryValue* dict) { ...@@ -404,7 +405,31 @@ void AddStringsForZipArchiver(base::DictionaryValue* dict) {
IDS_ZIP_ARCHIVER_PASSPHRASE_TITLE); IDS_ZIP_ARCHIVER_PASSPHRASE_TITLE);
} }
void AddStringsForDefault(base::DictionaryValue* dict) { } // namespace
namespace extensions {
FileManagerPrivateGetStringsFunction::FileManagerPrivateGetStringsFunction() =
default;
FileManagerPrivateGetStringsFunction::~FileManagerPrivateGetStringsFunction() =
default;
ExtensionFunction::ResponseAction FileManagerPrivateGetStringsFunction::Run() {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
AddStringsForDrive(dict.get());
AddStringsForMediaView(dict.get());
AddStringsForFileTypes(dict.get());
AddStringsForGallery(dict.get());
AddStringsForMediaPlayer(dict.get());
AddStringsForVideoPlayer(dict.get());
AddStringsForAudioPlayer(dict.get());
AddStringsForCloudImport(dict.get());
AddStringsForCrUiMenuItemShortcuts(dict.get());
AddStringsForFileErrors(dict.get());
AddStringsForZipArchiver(dict.get());
SET_STRING("ADD_NEW_SERVICES_BUTTON_LABEL", SET_STRING("ADD_NEW_SERVICES_BUTTON_LABEL",
IDS_FILE_BROWSER_ADD_NEW_SERVICES_BUTTON_LABEL); IDS_FILE_BROWSER_ADD_NEW_SERVICES_BUTTON_LABEL);
SET_STRING("ALL_FILES_FILTER", IDS_FILE_BROWSER_ALL_FILES_FILTER); SET_STRING("ALL_FILES_FILTER", IDS_FILE_BROWSER_ALL_FILES_FILTER);
...@@ -785,6 +810,19 @@ void AddStringsForDefault(base::DictionaryValue* dict) { ...@@ -785,6 +810,19 @@ void AddStringsForDefault(base::DictionaryValue* dict) {
SET_STRING("SEE_MENU_FOR_ACTIONS", IDS_FILE_BROWSER_SEE_MENU_FOR_ACTIONS); SET_STRING("SEE_MENU_FOR_ACTIONS", IDS_FILE_BROWSER_SEE_MENU_FOR_ACTIONS);
#undef SET_STRING #undef SET_STRING
dict->SetBoolean("PDF_VIEW_ENABLED",
file_manager::util::ShouldBeOpenedWithPlugin(
Profile::FromBrowserContext(browser_context()),
FILE_PATH_LITERAL(".pdf")));
dict->SetBoolean("SWF_VIEW_ENABLED",
file_manager::util::ShouldBeOpenedWithPlugin(
Profile::FromBrowserContext(browser_context()),
FILE_PATH_LITERAL(".swf")));
// TODO(crbug.com/868747): Find a better solution for demo mode.
dict->SetBoolean("HIDE_SPACE_INFO",
chromeos::DemoSession::IsDeviceInDemoMode());
dict->SetString("CHROMEOS_RELEASE_BOARD",
base::SysInfo::GetLsbReleaseBoard());
dict->SetString( dict->SetString(
"DOWNLOADS_LOW_SPACE_WARNING_HELP_URL", "DOWNLOADS_LOW_SPACE_WARNING_HELP_URL",
base::StringPrintf(kHelpURLFormat, kDownloadsLowSpaceWarningHelpNumber)); base::StringPrintf(kHelpURLFormat, kDownloadsLowSpaceWarningHelpNumber));
...@@ -803,63 +841,9 @@ void AddStringsForDefault(base::DictionaryValue* dict) { ...@@ -803,63 +841,9 @@ void AddStringsForDefault(base::DictionaryValue* dict) {
"NO_TASK_FOR_FILE_URL", "NO_TASK_FOR_FILE_URL",
base::StringPrintf(kHelpURLFormat, kNoActionForFileHelpNumber)); base::StringPrintf(kHelpURLFormat, kNoActionForFileHelpNumber));
dict->SetString("UI_LOCALE", extension_l10n_util::CurrentLocaleOrDefault()); dict->SetString("UI_LOCALE", extension_l10n_util::CurrentLocaleOrDefault());
}
} // namespace
namespace extensions {
std::unique_ptr<base::DictionaryValue> FileManagerPrivateStrings::GetStrings(
const std::string& app_locale,
bool pdf_view_enabled,
bool swf_view_enabled,
bool is_device_in_demo_mode,
const std::string& lsb_release_board) {
std::unique_ptr<base::DictionaryValue> dict =
std::make_unique<base::DictionaryValue>();
AddStringsForDrive(dict.get());
AddStringsForMediaView(dict.get());
AddStringsForFileTypes(dict.get());
AddStringsForGallery(dict.get());
AddStringsForMediaPlayer(dict.get());
AddStringsForVideoPlayer(dict.get());
AddStringsForAudioPlayer(dict.get());
AddStringsForCloudImport(dict.get());
AddStringsForCrUiMenuItemShortcuts(dict.get());
AddStringsForFileErrors(dict.get());
AddStringsForZipArchiver(dict.get());
AddStringsForDefault(dict.get());
dict->SetBoolean("PDF_VIEW_ENABLED", pdf_view_enabled);
dict->SetBoolean("SWF_VIEW_ENABLED", swf_view_enabled);
dict->SetBoolean("HIDE_SPACE_INFO", is_device_in_demo_mode);
dict->SetString("CHROMEOS_RELEASE_BOARD", lsb_release_board);
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, dict.get()); webui::SetLoadTimeDataDefaults(app_locale, dict.get());
return dict;
}
FileManagerPrivateGetStringsFunction::FileManagerPrivateGetStringsFunction() =
default;
FileManagerPrivateGetStringsFunction::~FileManagerPrivateGetStringsFunction() =
default;
ExtensionFunction::ResponseAction FileManagerPrivateGetStringsFunction::Run() {
bool pdf_view_enabled = file_manager::util::ShouldBeOpenedWithPlugin(
Profile::FromBrowserContext(browser_context()),
FILE_PATH_LITERAL(".pdf"));
bool swf_view_enabled = file_manager::util::ShouldBeOpenedWithPlugin(
Profile::FromBrowserContext(browser_context()),
FILE_PATH_LITERAL(".swf"));
std::unique_ptr<base::DictionaryValue> dict =
FileManagerPrivateStrings::GetStrings(
g_browser_process->GetApplicationLocale(), pdf_view_enabled,
swf_view_enabled,
// TODO(crbug.com/868747): Find a better solution for demo mode.
chromeos::DemoSession::IsDeviceInDemoMode(),
base::SysInfo::GetLsbReleaseBoard());
return RespondNow(OneArgument(std::move(dict))); return RespondNow(OneArgument(std::move(dict)));
} }
......
...@@ -7,27 +7,10 @@ ...@@ -7,27 +7,10 @@
#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_STRINGS_H_ #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_STRINGS_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_STRINGS_H_ #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_STRINGS_H_
#include <memory>
#include "base/values.h"
#include "chrome/browser/extensions/chrome_extension_function.h" #include "chrome/browser/extensions/chrome_extension_function.h"
namespace extensions { namespace extensions {
class FileManagerPrivateStrings {
public:
// Returns dictionary of all strings for FileManager app.
// This public static function is used by the ExtensionFunction
// below and also made accessible to be run as part of the build
// process and provide strings for file manager testing environments.
static std::unique_ptr<base::DictionaryValue> GetStrings(
const std::string& app_locale,
bool pdf_view_enabled,
bool swf_view_enabled,
bool is_device_in_demo_mode,
const std::string& lsb_release_board);
};
// Implements the chrome.fileManagerPrivate.getStrings method. // Implements the chrome.fileManagerPrivate.getStrings method.
// Used to get strings for the file manager from JavaScript. // Used to get strings for the file manager from JavaScript.
class FileManagerPrivateGetStringsFunction : public UIThreadExtensionFunction { class FileManagerPrivateGetStringsFunction : public UIThreadExtensionFunction {
......
# Copyright 2018 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.
executable("file_manager_strings") {
testonly = true
sources = [
"file_manager_strings.cc",
]
deps = [
"//base",
"//chrome/browser/chromeos",
"//ui/base",
]
}
// Copyright 2018 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 <iostream>
#include <memory>
#include <string>
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/values.h"
#include "chrome/browser/chromeos/extensions/file_manager/private_api_strings.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
// Prints a JSON dict of the file manager strings
// (fileManagerPrivate.getStrings) to stdout.
// It is used as part of the build process to extract strings for
// file manager tests.
int main(int argc, char** argv) {
base::AtExitManager at_exit;
base::CommandLine::Init(argc, argv);
// Load resource bundle to get locales/en-US.pak.
ui::RegisterPathProvider();
ui::ResourceBundle::InitSharedInstanceWithLocale(
"en-US", nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
// Get FileManager strings as JS dict.
std::unique_ptr<base::Value> dict =
extensions::FileManagerPrivateStrings::GetStrings(
"en-US", // app_locale
false, // pdf_view_enabled
false, // swf_view_enabled
false, // is_device_in_demo_mode
"unknown"); // lsb_release_board
// Print JSON to stdout.
std::string json;
base::JSONWriter::WriteWithOptions(
*dict, base::JSONWriter::Options::OPTIONS_PRETTY_PRINT, &json);
std::cout << json;
}
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
action("create_test_main") { action("create_test_main") {
testonly = true
script = "//ui/file_manager/file_manager/test/scripts/create_test_main.py" script = "//ui/file_manager/file_manager/test/scripts/create_test_main.py"
output = "$target_gen_dir/../test.html" output = "$target_gen_dir/../test.html"
sources = [ sources = [
...@@ -24,11 +23,7 @@ action("create_test_main") { ...@@ -24,11 +23,7 @@ action("create_test_main") {
"quick_view.js", "quick_view.js",
"uma.js", "uma.js",
] ]
args = [ args = [ "--output=" + rebase_path(output, root_build_dir) ]
"--output=" + rebase_path(output, root_build_dir),
"--file_manager_strings=" +
rebase_path("$root_out_dir/file_manager_strings"),
]
outputs = [ outputs = [
output, output,
"$target_gen_dir/gen/css/text_defaults.css", "$target_gen_dir/gen/css/text_defaults.css",
...@@ -38,9 +33,6 @@ action("create_test_main") { ...@@ -38,9 +33,6 @@ action("create_test_main") {
"$target_gen_dir/gen/elements/files_safe_media.js", "$target_gen_dir/gen/elements/files_safe_media.js",
"$target_gen_dir/gen/js/elements_importer.js", "$target_gen_dir/gen/js/elements_importer.js",
] ]
deps = [
"//chrome/browser/chromeos/extensions/file_manager/test:file_manager_strings",
]
} }
js_type_check("closure_compile") { js_type_check("closure_compile") {
......
...@@ -2,10 +2,152 @@ ...@@ -2,10 +2,152 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// loadTimeData contains localized content. It is populated with // loadTimeData contains localized content.
// FileManager strings during build. // Auto convert strings where possible using the id.
// e.g. NEW_FILE_BUTTON_LABEL => 'New file'
// Use a Proxy class to intercept get calls.
loadTimeData.data = $DATA; loadTimeData.data = new Proxy(
{
AUDIO_FILE_TYPE: '$1 audio',
CANCEL_LABEL: 'Cancel',
CHANGE_DEFAULT_MENU_ITEM: 'Change default...',
CHROMEOS_RELEASE_BOARD: 'unknown',
COPY_FILE_NAME: 'Copying $1...',
COPY_ITEMS_REMAINING: 'Copying $1 items...',
DEFAULT_NEW_FOLDER_NAME: 'New Folder',
DEFAULT_TASK_LABEL: '(default)',
DELETE_FILE_NAME: 'Deleting "$1"...',
DEVICE_ACCESS_RESTRICTED: 'Access restricted',
DIRECTORY_ALREADY_EXISTS: 'The folder named "$1" already exists. ' +
'Please choose a different name.',
DOWNLOADS_DIRECTORY_LABEL: 'Downloads',
DATE_COLUMN_LABEL: 'Date modified',
DELETE_ITEMS_REMAINING: 'Deleting $1 items...',
DRIVE_BUY_MORE_SPACE: 'Buy more storage...',
DRIVE_DIRECTORY_LABEL: 'Google Drive',
DRIVE_MENU_HELP: 'Help',
DRIVE_MOBILE_CONNECTION_OPTION: 'Do not use mobile data for sync',
DRIVE_MY_DRIVE_LABEL: 'My Drive',
DRIVE_NOT_REACHED: 'Google Drive could not be reached. ' +
'Please <a href="javascript://">log out</a> and log back in.',
DRIVE_OFFLINE_COLLECTION_LABEL: 'Offline',
DRIVE_SHARED_WITH_ME_COLLECTION_LABEL: 'Shared with me',
DRIVE_SHOW_HOSTED_FILES_OPTION: 'Show Google Docs files',
DRIVE_TEAM_DRIVES_LABEL: 'Team Drives',
DRIVE_VISIT_DRIVE_GOOGLE_COM: 'Go to drive.google.com...',
DRIVE_WELCOME_CHECK_ELIGIBILITY: 'Check eligibility',
DRIVE_WELCOME_DISMISS: 'Dismiss',
DRIVE_WELCOME_TEXT_LONG: '<p><strong>Access files from everywhere, ' +
'even offline.</strong> Files in Google Drive are up to date and ' +
'available from any device.</p><p><strong>Keep your files safe.' +
'</strong> No matter what happens to your device, your files are ' +
'safely stored in Google Drive.</p><p><strong>Share, create and ' +
'collaborate</strong> on files with others all in one place.</p>',
DRIVE_WELCOME_TEXT_SHORT:
'All files saved in this folder are backed up online automatically',
DRIVE_WELCOME_TITLE_ALTERNATIVE: 'Get 100 GB free with Google Drive',
EMPTY_FOLDER: 'Nothing to see here...',
ERROR_LINUX_FILES_CONNECTION: 'Unable to view Linux files',
FILENAME_LABEL: 'File name',
GALLERY_CONFIRM_DELETE_ONE: 'Are you sure you want to delete "$1"?',
GALLERY_CONFIRM_DELETE_SOME: 'Are you sure you want to delete $1 items?',
GDOC_DOCUMENT_FILE_TYPE: 'Google document',
GENERIC_FILE_TYPE: '$1 file',
GOOGLE_DRIVE_REDEEM_URL: 'http://www.google.com/intl/en/chrome/' +
'devices/goodies.html?utm_source=filesapp&utm_medium=banner&' +
'utm_campaign=gsg',
HIDE_SPACE_INFO: false,
IMAGE_FILE_TYPE: '$1 image',
INSTALL_LINUX_PACKAGE_INSTALL_BUTTON: 'Install',
INSTALL_NEW_EXTENSION_LABEL: 'Install new service',
LINUX_FILES_ROOT_LABEL: 'Linux files',
MANY_DIRECTORIES_SELECTED: '$1 folders selected',
MANY_ENTRIES_SELECTED: '$1 items selected',
MANY_FILES_SELECTED: '$1 files selected',
METADATA_BOX_ALBUM_TITLE: 'Album',
METADATA_BOX_MEDIA_MIME_TYPE: 'Type',
METADATA_BOX_MODIFICATION_TIME: 'Modified time',
MOVE_FILE_NAME: 'Moving $1...',
MOVE_ITEMS_REMAINING: 'Moving $1 items...',
MY_FILES_ROOT_LABEL: 'My files',
NAME_COLUMN_LABEL: 'Name',
OFFLINE_COLUMN_LABEL: 'Available offline',
OPEN_WITH_VERB_BUTTON_LABEL: 'Open with $1',
OK_LABEL: 'OK',
ONE_DIRECTORY_SELECTED: '1 folder selected',
ONE_FILE_SELECTED: '1 file selected',
OPENING_LINUX_FILES: 'Opening Linux files...',
OPEN_LABEL: 'Open',
PLAIN_TEXT_FILE_TYPE: 'Plain text',
PREPARING_LABEL: 'Preparing',
SEE_MENU_FOR_ACTIONS: 'More options available on the action bar. ' +
'Press Alt + A to focus the action bar.',
SHARE_WITH_LINUX_BUTTON_LABEL: 'Share with Linux',
SIZE_COLUMN_LABEL: 'Size',
SPACE_AVAILABLE: '$1 available',
STATUS_COLUMN_LABEL: 'Status',
TIME_TODAY: 'Today $1',
TYPE_COLUMN_LABEL: 'Type',
UI_LOCALE: 'en_US',
RECENT_ROOT_LABEL: 'Recent',
SEARCH_TEXT_LABEL: 'Search',
SELECT_ALL_COMMAND_LABEL: 'Select all',
SHOW_ALL_ANDROID_FOLDERS_OPTION: 'Show all Play folders',
SIZE_BYTES: '$1 bytes',
SIZE_GB: '$1 GB',
SIZE_KB: '$1 KB',
SIZE_PB: '$1 PB',
SUGGEST_DIALOG_INSTALLATION_FAILED: 'Installation failed.',
SUGGEST_DIALOG_INSTALLING_SPINNER_ALT: 'Installing',
SUGGEST_DIALOG_LINK_TO_WEBSTORE: 'See more...',
SUGGEST_DIALOG_LOADING_SPINNER_ALT: 'Loading',
SUGGEST_DIALOG_TITLE: 'Select an app to open this file',
TASK_OPEN: 'Open',
TASK_VIEW: 'View',
TOGGLE_HIDDEN_FILES_COMMAND_LABEL: 'Show hidden files',
UNABLE_TO_OPEN_CROSTINI_TITLE: 'Unable to open with $1',
UNABLE_TO_OPEN_CROSTINI:
'To open files with $1, first copy to Linux files folder.',
VIDEO_FILE_TYPE: '$1 video',
WAITING_FOR_SPACE_INFO: 'Waiting for space info...',
language: 'en',
textdirection: 'ltr',
},
{
get: (target, prop) => {
// Return any specific result from above.
if (prop in target)
return target[prop];
// Single word as-is.
if (!prop.includes('_')) {
return prop.substring(0, 1) + prop.substring(1).toLowerCase();
}
// List of regexps to match against for auto-convert.
var autoConvert = [
/^CLOUD_IMPORT_/,
/^DRIVE_SHARE_TYPE_/,
/^METADATA_BOX_EXIF_/,
/^METADATA_BOX_FILE_/,
/^METADATA_BOX_MEDIA_/,
/^METADATA_BOX_/,
/^QUICK_VIEW_/,
/^SHORTCUT_/,
/_BUTTON_LABEL$/,
/_BUTTON_TOOLTIP$/,
];
for (var i = 0; i < autoConvert.length; i++) {
if (prop.match(autoConvert[i])) {
// Keep first capital, lower case the rest, convert '_' to ' '.
var r = prop.replace(autoConvert[i], '');
return r.substring(0, 1) +
r.substring(1).toLowerCase().replace(/_/g, ' ');
}
}
console.error('Unknown loadTimeData [' + prop + ']');
return prop;
}
});
// Overwrite LoadTimeData.prototype.data setter as nop. // Overwrite LoadTimeData.prototype.data setter as nop.
// Default implementation throws errors when both background and // Default implementation throws errors when both background and
......
...@@ -13,7 +13,6 @@ as a regular web page in a single renderer. ...@@ -13,7 +13,6 @@ as a regular web page in a single renderer.
import argparse import argparse
import os import os
import subprocess
import sys import sys
import time import time
...@@ -22,17 +21,17 @@ assert __name__ == '__main__' ...@@ -22,17 +21,17 @@ assert __name__ == '__main__'
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--output') parser.add_argument('--output')
parser.add_argument('--file_manager_strings')
args = parser.parse_args() args = parser.parse_args()
if not (args.output and args.file_manager_strings): # If --output is not provided, write to local test.html.
parser.error('--output and --file_manager_strings flags required') output = args.output or os.path.abspath(
os.path.join(sys.path[0], '../../test.html'))
# ROOT_SRC: Absolute path to src //ui/file_manager/file_manager. # ROOT_SRC: Absolute path to src //ui/file_manager/file_manager.
# ROOT_GEN: Absolute path to $target_gen_dir of ROOT_SRC. # ROOT_GEN: Absolute path to $target_gen_dir of ROOT_SRC.
# ROOT : Relative path from ROOT_GEN to ROOT_SRC. # ROOT : Relative path from ROOT_GEN to ROOT_SRC.
ROOT_SRC = os.path.abspath(os.path.join(sys.path[0], '../..')) ROOT_SRC = os.path.abspath(os.path.join(sys.path[0], '../..'))
ROOT_GEN = os.path.dirname(os.path.abspath(args.output)) ROOT_GEN = os.path.dirname(os.path.abspath(output))
ROOT = os.path.relpath(ROOT_SRC, ROOT_GEN) + '/' ROOT = os.path.relpath(ROOT_SRC, ROOT_GEN) + '/'
scripts = [] scripts = []
GENERATED = 'Generated at %s by: %s' % (time.ctime(), sys.path[0]) GENERATED = 'Generated at %s by: %s' % (time.ctime(), sys.path[0])
...@@ -160,28 +159,24 @@ main_html = replaceline(main_html, 'foreground/js/main_scripts.js', [ ...@@ -160,28 +159,24 @@ main_html = replaceline(main_html, 'foreground/js/main_scripts.js', [
def elements_path(elements_filename): def elements_path(elements_filename):
return '="../../../../%sforeground/elements/%s' % (ROOT, elements_filename) return '="../../../%sforeground/elements/%s' % (ROOT, elements_filename)
# Populate strings.
# Fix relative file paths in elements_bundle.html # Fix relative file paths in elements_bundle.html
# Load QuickView in iframe rather than webview. # Load QuickView in iframe rather than webview.
# Change references in files_quick_view.html to use updated # Change references in files_quick_view.html to use updated
# files_safe_media.html which will use webview rather than iframe, # files_safe_media.html which will use webview rather than iframe,
# and sets src directly on iframe. # and sets src directly on iframe.
for filename, substitutions in ( for filename, substitutions in (
('test/js/strings.js', ( ('elements/elements_bundle.html', (
('$DATA', subprocess.check_output([args.file_manager_strings])),
)),
('foreground/elements/elements_bundle.html', (
('="files_ripple', elements_path('files_ripple')), ('="files_ripple', elements_path('files_ripple')),
('="files_toggle_ripple', elements_path('files_toggle_ripple')), ('="files_toggle_ripple', elements_path('files_toggle_ripple')),
('="files_tooltip', elements_path('files_tooltip')), ('="files_tooltip', elements_path('files_tooltip')),
('="icons', elements_path('icons')), ('="icons', elements_path('icons')),
)), )),
('foreground/js/elements_importer.js', ( ('js/elements_importer.js', (
("= 'foreground", "= 'test/gen/foreground"), ("= 'foreground", "= 'test/gen"),
)), )),
('foreground/elements/files_quick_view.html', ( ('elements/files_quick_view.html', (
('="files_icon', elements_path('files_icon')), ('="files_icon', elements_path('files_icon')),
('="files_metadata', elements_path('files_metadata')), ('="files_metadata', elements_path('files_metadata')),
('="files_tooltip', elements_path('files_tooltip')), ('="files_tooltip', elements_path('files_tooltip')),
...@@ -189,8 +184,8 @@ for filename, substitutions in ( ...@@ -189,8 +184,8 @@ for filename, substitutions in (
('="icons', elements_path('icons')), ('="icons', elements_path('icons')),
('webview', 'iframe'), ('webview', 'iframe'),
)), )),
('foreground/elements/files_safe_media.html', (('webview', 'iframe'),)), ('elements/files_safe_media.html', (('webview', 'iframe'),)),
('foreground/elements/files_safe_media.js', ( ('elements/files_safe_media.js', (
("'foreground/elements", "'%sforeground/elements" % ROOT), ("'foreground/elements", "'%sforeground/elements" % ROOT),
("'webview'", "'iframe'"), ("'webview'", "'iframe'"),
("'contentload'", "'load'"), ("'contentload'", "'load'"),
...@@ -199,11 +194,11 @@ for filename, substitutions in ( ...@@ -199,11 +194,11 @@ for filename, substitutions in (
'this.webview_.contentWindow.content.src = this.src;')), 'this.webview_.contentWindow.content.src = this.src;')),
)), )),
): ):
buf = read(filename) buf = read('foreground/' + filename)
for old, new in substitutions: for old, new in substitutions:
buf = buf.replace(old, new) buf = buf.replace(old, new)
write('test/gen/' + filename, buf) write('test/gen/' + filename, buf)
main_html = replaceline(main_html, filename, main_html = replaceline(main_html, 'foreground/' + filename,
['<script src="test/gen/%s"></script>' % filename]) ['<script src="test/gen/%s"></script>' % filename])
test_html = GENERATED_HTML + '\n'.join(main_html) test_html = GENERATED_HTML + '\n'.join(main_html)
......
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