Commit fd924e72 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Add fileManagerPrivate getContentMimeType getContentMetadata tests

Test files come from //media/test/data. Change apitest C++ to copy the
files to the 'testing' Volume before starting tests.

  id3_png_test.mp3: audio file with embedded album artwork image
  90rotation.mp4: h264 video, with 90 degree rotation, no images

Add test JS helpers to read the files from the 'testing' volume / file
system and convert them to Blobs before starting the tests.

Add fileManagerPrivate.getContentMimeType mime sniffing tests:

 testGetContentMimeTypeEmpty
   - input is an empty blob, returns undefined mimeType result
 testGetContentMimeTypeImage
   - input is an image file blob, sniff image/gif
 testGetContentMimeTypeAudio
   - input is an audio file blob, sniff audio/mpeg
 testGetContentMimeTypeVideo
   - input is a video file blob, sniff video/mp4
 testGetContentMimeTypeUnknownMimeTypeError
   - net::mime_sniffer fails, sets chrome.runtime.LastError

Add fileManagerPrivate.getContentMetadata metadata extraction tests:

 testGetContentMetadataEmpty
   - input is an empty blob, returns undefined MediaMetadata
 testGetContentMetadataAudioTags
   - extract tags only into the MediaMetadata result
   - vet result with JS verifyExpectedAudioMetadata() helper
 testGetContentMetadataAudioTagsImages
   - extract tags and images into the MediaMetadata result
   - vet result with JS verifyExpectedAudioMetadata() helper
 testGetContentMetadataVideoTagsImages
   - extract tags and images into the MediaMetadata result
   - vet result with verifyExpectedVideoMetadata() helper
 testGetContentMetadataRetainsInputMimeType
   - input mime type is copied through to MediaMetadata.mimeType
 testGetContentMetadataVideoResetsAudioMime
   - audio mime is changed to video if there is width and height
 testGetContentMetadataUnsupportedMimetypeError
   - input mime not video or audio, sets chrome.runtime.LastError

Bug: 1114622
Change-Id: Ic96ce7faa409ae25d6b3c956666bbfd7db362f25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2345936
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797078}
parent e697f4f1
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2012 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.
......@@ -9,6 +9,7 @@
#include "base/base64.h"
#include "base/bind.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
......@@ -463,6 +464,35 @@ IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, Recent) {
ASSERT_TRUE(RunComponentExtensionTest("file_browser/recent_test"));
}
IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, MediaMetadata) {
const base::FilePath test_dir = temp_dir_.GetPath();
AddLocalFileSystem(browser()->profile(), test_dir);
// Get the source tree media/test/data directory path.
base::FilePath root_dir;
CHECK(base::PathService::Get(base::DIR_SOURCE_ROOT, &root_dir));
const base::FilePath media_test_data_dir =
root_dir.AppendASCII("media").AppendASCII("test").AppendASCII("data");
// Returns a path to a media/test/data test file.
auto get_media_test_data_file = [&](const std::string& file) {
return media_test_data_dir.Append(base::FilePath::FromUTF8Unsafe(file));
};
// Create test files.
{
base::ScopedAllowBlockingForTesting allow_io;
const base::FilePath video = get_media_test_data_file("90rotation.mp4");
ASSERT_TRUE(base::CopyFile(video, test_dir.Append(video.BaseName())));
const base::FilePath audio = get_media_test_data_file("id3_png_test.mp3");
ASSERT_TRUE(base::CopyFile(audio, test_dir.Append(audio.BaseName())));
}
ASSERT_TRUE(RunComponentExtensionTest("file_browser/media_metadata"));
}
IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, Crostini) {
crostini::FakeCrostiniFeatures crostini_features;
crostini_features.set_ui_allowed(true);
......
{
// chrome-extension://pkplfbidichfdicaijlchgnapepdginl
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtDfX9dHNh948bt00YhZBm3P6E5QLaOt+v8kXVtibQfiPtOD2FTScB/f0wX/EQWVO7BkaSOsRkTPcPIgocyMPYr2FLgqGLFlYT9nQpKJZUFNF5oJ5rG6Nv7ppf4zEB3j6da1IBRTz2yOZ+6O1TMZxol/V62/QcqrJeggsHTEPGLdr9Ua4b1Ka0xKJnJngZljsbw93FI1o+P9dAh5BS6wTPiZI/vmJVjvMTkSTnaZ3n9Go2t7A0XLcSxLcVyuLAd2mAvSN0mIviOukdM66wr7llif71nKuUt+4qvlr/r9HfwzN6pA4jkwhtS1UD+3CmB+wsHwsnohNcuu4FIQ6rgq/7QIDAQAB",
"name": "chrome.fileManagerPrivate tests",
"version": "0.1",
"manifest_version": 2,
"description": "Tests chrome.fileManagerPrivate.getContetMimeType and getContentMetadata",
"app": {
"background": {
"scripts": ["test.js"]
}
},
"permissions": [
"fileManagerPrivate",
{
"fileSystem": ["requestFileSystem"]
}
]
}
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