Commit fa29fa99 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Chromium LUCI CQ

Files app: Generate JS module for //u/f/f/b/j/drive_sync_handler.js

Files:
- //u/f/f/b/j/drive_sync_handler_unittest.m.js
- //u/f/f/b/j/drive_sync_handler.js

Bug: 1133186
Change-Id: I463c68a02bb942415b8d66161855d74bbc0b0c45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595556
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837951}
parent 8e3f3bf7
......@@ -54,7 +54,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DirectoryTreeTest) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DriveSyncHandlerTest) {
RunTestURL("background/js/drive_sync_handler_unittest_gen.html");
RunTestURL("background/js/drive_sync_handler_unittest.m_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DuplicateFinderTest) {
......
......@@ -77,6 +77,7 @@ js_type_check("closure_compile_jsmodules") {
":app_windows.m",
":background_base.m",
":crostini.m",
":drive_sync_handler.m",
":entry_location_impl.m",
":file_operation_util.m",
":import_history.m",
......@@ -349,13 +350,29 @@ js_library("drive_sync_handler") {
[ "//ui/file_manager/externs/background/drive_sync_handler.js" ]
}
js_unittest("drive_sync_handler_unittest") {
js_library("drive_sync_handler.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/drive_sync_handler.m.js" ]
deps = [
":drive_sync_handler",
":file_operation_util",
":mock_progress_center",
"//ui/file_manager/base/js:mock_chrome",
"//ui/file_manager/base/js:test_error_reporting",
":file_operation_util.m",
"//ui/file_manager/externs/background:drive_sync_handler.m",
"//ui/file_manager/externs/background:progress_center.m",
"//ui/file_manager/file_manager/common/js:async_util.m",
"//ui/file_manager/file_manager/common/js:progress_center_common.m",
"//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js/cr:event_target.m",
]
extra_deps = [ ":modulize" ]
}
js_unittest("drive_sync_handler_unittest.m") {
deps = [
":drive_sync_handler.m",
":mock_progress_center.m",
"//chrome/test/data/webui:chai_assert",
"//ui/file_manager/base/js:mock_chrome.m",
"//ui/file_manager/file_manager/common/js:progress_center_common.m",
"//ui/webui/resources/js:load_time_data.m",
]
}
......@@ -934,6 +951,7 @@ js_library("volume_manager_util.m") {
js_test_gen_html("js_test_gen_html_modules") {
deps = [
":crostini_unittest.m",
":drive_sync_handler_unittest.m",
":import_history_unittest.m",
":metadata_proxy_unittest.m",
":mount_metrics_unittest.m",
......@@ -953,7 +971,6 @@ js_test_gen_html("js_test_gen_html_modules") {
js_test_gen_html("js_test_gen_html") {
deps = [
":device_handler_unittest",
":drive_sync_handler_unittest",
":duplicate_finder_unittest",
":file_operation_handler_unittest",
":file_operation_manager_unittest",
......@@ -988,6 +1005,7 @@ js_modulizer("modulize") {
"task_queue.js",
"test_import_history.js",
"import_history.js",
"drive_sync_handler.js",
]
namespace_rewrites = cr_namespace_rewrites
......
......@@ -2,11 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {ProgressCenter} from '../../../externs/background/progress_center.m.js';
// #import {DriveSyncHandler} from '../../../externs/background/drive_sync_handler.m.js';
// #import {str, strf} from '../../common/js/util.m.js';
// #import {fileOperationUtil} from './file_operation_util.m.js';
// #import {AsyncUtil} from '../../common/js/async_util.m.js';
// #import {ProgressCenterItem, ProgressItemState, ProgressItemType} from '../../common/js/progress_center_common.m.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// clang-format on
/**
* Handler of the background page for the Drive sync events.
* @implements {DriveSyncHandler}
*/
class DriveSyncHandlerImpl extends cr.EventTarget {
/* #export */ class DriveSyncHandlerImpl extends cr.EventTarget {
/** @param {ProgressCenter} progressCenter */
constructor(progressCenter) {
super();
......
// 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.
'use strict';
// clang-format off
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {assertEquals,assertFalse, assertTrue} from 'chrome://test/chai_assert.js';
import {installMockChrome} from '../../../base/js/mock_chrome.m.js';
import {ProgressItemState} from '../../common/js/progress_center_common.m.js';
import {DriveSyncHandlerImpl} from './drive_sync_handler.m.js';
import {MockProgressCenter} from './mock_progress_center.m.js';
// clang-format on
/**
* @type {!MockProgressCenter}
......@@ -99,14 +109,12 @@ window.webkitResolveLocalFileSystemURL =
successCallback(/** @type {!Entry} */ ({name: url}));
};
// Mock window.str|strf string calls from drive sync handler.
window.str = (...args) => {
return args.join(' ');
};
window.strf = window.str;
// Set up the test components.
function setUp() {
export function setUp() {
// Mock LoadTimeData strings.
loadTimeData.data = {};
loadTimeData.getString = id => id;
// Install mock chrome APIs.
installMockChrome(mockChrome);
......@@ -121,7 +129,7 @@ function setUp() {
}
// Test that in general case item IDs produced for errors are unique.
function testUniqueErrorIds() {
export function testUniqueErrorIds() {
// Dispatch an event.
mockChrome.fileManagerPrivate.onDriveSyncError.listener_({
type: 'service_unavailable',
......@@ -142,7 +150,7 @@ function testUniqueErrorIds() {
}
// Test that item IDs produced for quota errors are same.
function testErrorDedupe() {
export function testErrorDedupe() {
// Dispatch an event.
mockChrome.fileManagerPrivate.onDriveSyncError.listener_({
type: 'no_server_space',
......@@ -162,7 +170,7 @@ function testErrorDedupe() {
assertEquals(1, progressCenter.getItemCount());
}
function testErrorWithoutPath() {
export function testErrorWithoutPath() {
const originalStub = window.webkitResolveLocalFileSystemURL;
/**
* Temporary stub the entry resolving to always fail.
......@@ -191,7 +199,7 @@ function testErrorWithoutPath() {
}
// Test offline.
async function testOffline() {
export async function testOffline() {
// Start a transfer.
await mockChrome.fileManagerPrivate.onFileTransfersUpdated.listener_({
fileUrl: 'name',
......@@ -222,7 +230,7 @@ async function testOffline() {
}
// Test transfer status updates.
async function testTransferUpdate() {
export async function testTransferUpdate() {
// Start a pin transfer.
await mockChrome.fileManagerPrivate.onPinTransfersUpdated.listener_({
fileUrl: 'name',
......
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