Reland "Build Karma test with Ninja"
This reverts commit 01ac2b90b3893b8355208cbba7ce8ee9c18e53ec.
Reason for revert: Build fixed in Chromium
Original change's description:
> Revert "Build Karma test with Ninja"
>
> This reverts commit 4b654444ed5ef198c8551503670895d67ae7856a.
>
> Reason for revert: Broke the build in Chromium: https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8887844056671365856/+/steps/compile__with_patch_/0/stdout
>
> Original change's description:
> > Build Karma test with Ninja
> >
> > This instructs Ninja to generate the appropriate files for the test
> > files. It adds a separate `ts_library` definition for tests.
> >
> > Some caveats:
> > - It currently hardcodes the Ninja build output name. We should fix out
> > a solution on how to make this irrespective of build name
> > - The test name has to be renamed to Color_test.ts. While I think this
> > is clearer for code navigation, it was necessary because `ts_library`
> > currently copies to `resources/inspector`, which is not necessary for
> > test files. We could therefore filter these out, based on the files that
> > end with `_test.ts`. We could also add a separate Ninja template,
> > something like `ts_test_library`. Not sure yet what is the best
> > approach.
> >
> > DISABLE_THIRD_PARTY_CHECK=Updating TypeScript configuration
> >
> > Bug: 1011811
> > Change-Id: If7448474e84a013d8d4b00a16743575a12112f58
> > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2064669
> > Reviewed-by: Jack Franklin <[email protected]>
> > Commit-Queue: Tim van der Lippe <[email protected]>
>
> [email protected],[email protected],[email protected]
>
> Change-Id: I1048a5003b5680b257586cf3720fc5eaddb435d5
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1011811
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2067061
> Reviewed-by: Tim van der Lippe <[email protected]>
> Commit-Queue: Tim van der Lippe <[email protected]>
DISABLE_THIRD_PARTY_CHECK=Reland
Bug: 1011811
Change-Id: I9df8d551a18c7733fca586f504621c18262e941d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2067062
Commit-Queue: Tim van der Lippe <[email protected]>
Reviewed-by: Paul Lewis <[email protected]>
diff --git a/BUILD.gn b/BUILD.gn
index 4c37562..571501e 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2257,6 +2257,17 @@
]
}
+# It is unclear why, but the Android Ninja configuration starts warning about
+# duplicate files being generated. This does not happen for regular Chromium
+# builds. Since we don't run these tests on Android any case, we disable
+# the generation of the tests on Android.
+if (!is_android) {
+ devtools_frontend_resources_deps += [
+ ":copy_karma_conf",
+ "test/unittests/front_end/common",
+ ]
+}
+
group("devtools_frontend_resources") {
public_deps = devtools_frontend_resources_deps
}
@@ -2271,6 +2282,11 @@
outputs = [ "$resources_out_dir/{{source_file_part}}" ]
}
+copy("copy_karma_conf") {
+ sources = [ "test/unittests/front_end/karma.conf.js" ]
+ outputs = [ "$target_gen_dir/karma.conf.js" ]
+}
+
copy("copy_htaccess") {
sources = [ "htaccess" ]
outputs = [ "$resources_out_dir/.htaccess" ]
@@ -2288,9 +2304,7 @@
copy("copy_lighthouse_locale_files") {
sources = lighthouse_locale_files
- outputs = [
- "$resources_out_dir/lighthouse_worker/lighthouse/locales/{{source_file_part}}",
- ]
+ outputs = [ "$resources_out_dir/lighthouse_worker/lighthouse/locales/{{source_file_part}}" ]
}
copy("copy_wasm_deps") {
@@ -2513,25 +2527,6 @@
"//third_party/node/linux/node-linux-x64/",
]
}
-
- group("devtools_unittests") {
- data = [
- # Needed for isolate script to execute.
- "front_end/",
- "karma.conf.js",
- "node_modules/",
- "scripts/devtools_paths.py",
- "scripts/test/",
- "tests/unittests",
- "third_party/chrome/",
- "tsconfig.json",
- "//testing/scripts/common.py",
- "//testing/scripts/run_devtools_check.py",
- "//testing/xvfb.py",
- "//third_party/node/node.py",
- "//third_party/node/linux/node-linux-x64/",
- ]
- }
}
# TODO(1018122): remove out-datedly named duplicates
@@ -2571,23 +2566,4 @@
"//third_party/node/linux/node-linux-x64/",
]
}
-
- group("devtools_unit_tests") {
- data = [
- # Needed for isolate script to execute.
- "front_end/",
- "karma.conf.js",
- "node_modules/",
- "scripts/devtools_paths.py",
- "scripts/test/",
- "tests/unittests",
- "third_party/chrome/",
- "tsconfig.json",
- "//testing/scripts/common.py",
- "//testing/scripts/run_devtools_check.py",
- "//testing/xvfb.py",
- "//third_party/node/node.py",
- "//third_party/node/linux/node-linux-x64/",
- ]
- }
}
diff --git a/scripts/test/run_unittests.py b/scripts/test/run_unittests.py
index 503ceeb..da3c917 100755
--- a/scripts/test/run_unittests.py
+++ b/scripts/test/run_unittests.py
@@ -20,6 +20,8 @@
import test_helpers
import devtools_paths
+NINJA_BUILD_NAME = os.environ.get('NINJA_BUILD_NAME') or 'Release'
+
def run_tests(chrome_binary):
cwd = devtools_paths.devtools_root_path()
diff --git a/test/unittests/front_end/common/BUILD.gn b/test/unittests/front_end/common/BUILD.gn
new file mode 100644
index 0000000..41a2cff
--- /dev/null
+++ b/test/unittests/front_end/common/BUILD.gn
@@ -0,0 +1,11 @@
+import("../../../../third_party/typescript/typescript.gni")
+
+ts_library("common") {
+ deps = [ ":Color" ]
+}
+
+ts_library("Color") {
+ sources = [ "Color_test.ts" ]
+
+ deps = [ "../../../../front_end/common" ]
+}
diff --git a/test/unittests/front_end/common/Color.ts b/test/unittests/front_end/common/Color_test.ts
similarity index 66%
rename from test/unittests/front_end/common/Color.ts
rename to test/unittests/front_end/common/Color_test.ts
index 4d168e9..3ca3bfc 100644
--- a/test/unittests/front_end/common/Color.ts
+++ b/test/unittests/front_end/common/Color_test.ts
@@ -4,70 +4,70 @@
const {assert} = chai;
-import * as Common from '/front_end/common/common.js';
+import * as Color from '../../../../front_end/common/Color.js';
describe('Color', () => {
it('can be instantiated without issues', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
assert.deepEqual(color.rgba(), [0.5, 0.5, 0.5, 0.5], 'RGBA array was not set correctly');
assert.equal(color.asString(), 'testColor', 'original text was not set correctly');
assert.equal(color.format(), 'testFormat', 'format was not set correctly');
});
it('defaults RGBA value to 0 if the RGBA initializing value given was negative', () => {
- const color = new Common.Color.Color([-0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([-0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
assert.deepEqual(color.rgba(), [0, 0.5, 0.5, 0.5], 'RGBA array was not set correctly');
assert.equal(color.asString(), 'testColor', 'original text was not set correctly');
assert.equal(color.format(), 'testFormat', 'format was not set correctly');
});
it('defaults RGBA value to 1 if the RGBA initializing value given was above one', () => {
- const color = new Common.Color.Color([1.1, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([1.1, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
assert.deepEqual(color.rgba(), [1, 0.5, 0.5, 0.5], 'RGBA array was not set correctly');
assert.equal(color.asString(), 'testColor', 'original text was not set correctly');
assert.equal(color.format(), 'testFormat', 'format was not set correctly');
});
it('is able to create a color class from an HSVA value', () => {
- const color = Common.Color.Color.fromHSVA([0.5, 0.5, 0.5, 100]);
+ const color = Color.Color.fromHSVA([0.5, 0.5, 0.5, 100]);
assert.deepEqual(color.rgba(), [0.25, 0.49999999999999994, 0.5, 1], 'RGBA array was not set correctly');
assert.equal(color.asString(), 'hsla(180, 33%, 38%, 1)', 'original text was not set correctly');
assert.equal(color.format(), 'hsla', 'format was not set correctly');
});
it('is able to return the HSVA value of a color', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const hsva = color.hsva();
assert.deepEqual(hsva, [0, 0, 0.5, 0.5], 'HSVA was not calculated correctly');
});
it('is able to return the luminance of an RGBA value with the RGB values more than 0.03928', () => {
- const lum = Common.Color.Color.luminance([0.5, 0.5, 0.5, 0.5]);
+ const lum = Color.Color.luminance([0.5, 0.5, 0.5, 0.5]);
assert.equal(lum, 0.21404114048223255, 'luminance was not calculated correctly');
});
it('is able to return the luminance of an RGBA value with the RGB values less than 0.03928', () => {
- const lum = Common.Color.Color.luminance([0.03927, 0.03927, 0.03927, 0.5]);
+ const lum = Color.Color.luminance([0.03927, 0.03927, 0.03927, 0.5]);
assert.equal(lum, 0.003039473684210526, 'luminance was not calculated correctly');
});
it('is able to return a lighter luminance according to a given contrast value', () => {
- const result = Common.Color.Color.desiredLuminance(0.2, 2, true);
+ const result = Color.Color.desiredLuminance(0.2, 2, true);
assert.equal(result, 0.45, 'luminance was not calculated correctly');
});
it('is able to return a darker luminance according to a given contrast value', () => {
- const result = Common.Color.Color.desiredLuminance(0.2, 2, false);
+ const result = Color.Color.desiredLuminance(0.2, 2, false);
assert.equal(result, 0.075, 'luminance was not calculated correctly');
});
it('is able to return a darker luminance if the lighter one falls out of the inclusive range [0, 1]', () => {
- const result = Common.Color.Color.desiredLuminance(0.2, 5, true);
+ const result = Color.Color.desiredLuminance(0.2, 5, true);
assert.equal(result, 0, 'luminance was not calculated correctly');
});
it('is able to return canonical HSLA for a color', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.canonicalHSLA();
assert.deepEqual(result, [0, 0, 50, 0.5], 'canonical HSLA was not calculated correctly');
});
@@ -75,7 +75,7 @@
it('is able to calculate the contrast ratio between two colors', () => {
const firstColor = [1, 0, 0, 1];
const secondColor = [0, 0, 1, 1];
- const contrastRatio = Common.Color.Color.calculateContrastRatio(firstColor, secondColor);
+ const contrastRatio = Color.Color.calculateContrastRatio(firstColor, secondColor);
assert.equal(contrastRatio, 2.148936170212766, 'contrast ratio was not calculated correctly');
});
@@ -83,183 +83,183 @@
const firstColor = [1, 0, 0, 1];
const secondColor = [0, 0, 1, 1];
const result: number[] = [];
- Common.Color.Color.blendColors(firstColor, secondColor, result);
+ Color.Color.blendColors(firstColor, secondColor, result);
assert.deepEqual(result, [1, 0, 0, 1], 'colors were not blended successfully');
});
it('parses hex values', () => {
- assert.deepEqual(Common.Color.Color.parse('#FF00FF')!.rgba(), [1, 0, 1, 1]);
- assert.deepEqual(Common.Color.Color.parse('#F0F')!.rgba(), [1, 0, 1, 1]);
- assert.deepEqual(Common.Color.Color.parse('#F0F0')!.rgba(), [1, 0, 1, 0]);
- assert.deepEqual(Common.Color.Color.parse('#FF00FF00')!.rgba(), [1, 0, 1, 0]);
+ assert.deepEqual(Color.Color.parse('#FF00FF')!.rgba(), [1, 0, 1, 1]);
+ assert.deepEqual(Color.Color.parse('#F0F')!.rgba(), [1, 0, 1, 1]);
+ assert.deepEqual(Color.Color.parse('#F0F0')!.rgba(), [1, 0, 1, 0]);
+ assert.deepEqual(Color.Color.parse('#FF00FF00')!.rgba(), [1, 0, 1, 0]);
});
it('parses nickname values', () => {
- assert.deepEqual(Common.Color.Color.parse('red')!.rgba(), [1, 0, 0, 1]);
+ assert.deepEqual(Color.Color.parse('red')!.rgba(), [1, 0, 0, 1]);
});
it('parses rgb(a) values', () => {
- const colorOne = Common.Color.Color.parse('rgb(255, 255, 0)')!;
+ const colorOne = Color.Color.parse('rgb(255, 255, 0)')!;
assert.deepEqual(colorOne.rgba(), [1, 1, 0, 1]);
- const colorTwo = Common.Color.Color.parse('rgba(0, 255, 255, 0.5)')!;
+ const colorTwo = Color.Color.parse('rgba(0, 255, 255, 0.5)')!;
assert.deepEqual(colorTwo.rgba(), [0, 1, 1, 0.5]);
- const colorThree = Common.Color.Color.parse('rgb(255 255 255)')!;
+ const colorThree = Color.Color.parse('rgb(255 255 255)')!;
assert.deepEqual(colorThree.rgba(), [1, 1, 1, 1]);
- const colorFour = Common.Color.Color.parse('rgb(10% 10% 10%)')!;
+ const colorFour = Color.Color.parse('rgb(10% 10% 10%)')!;
assert.deepEqual(colorFour.rgba(), [0.1, 0.1, 0.1, 1]);
- const colorFive = Common.Color.Color.parse('rgb(10% 10% 10% / 0.4)')!;
+ const colorFive = Color.Color.parse('rgb(10% 10% 10% / 0.4)')!;
assert.deepEqual(colorFive.rgba(), [0.1, 0.1, 0.1, 0.4]);
});
it('parses hsl(a) values', () => {
- const colorOne = Common.Color.Color.parse('hsl(0, 100%, 50%)')!;
+ const colorOne = Color.Color.parse('hsl(0, 100%, 50%)')!;
assert.deepEqual(colorOne.rgba(), [1, 0, 0, 1]);
- const colorTwo = Common.Color.Color.parse('hsla(0, 100%, 50%, 0.5)')!;
+ const colorTwo = Color.Color.parse('hsla(0, 100%, 50%, 0.5)')!;
assert.deepEqual(colorTwo.rgba(), [1, 0, 0, 0.5]);
- const colorThree = Common.Color.Color.parse('hsla(50deg 100% 100% / 50%)')!;
+ const colorThree = Color.Color.parse('hsla(50deg 100% 100% / 50%)')!;
assert.deepEqual(colorThree.rgba(), [1, 1, 1, 0.5]);
});
it('handles invalid values', () => {
- assert.isNull(Common.Color.Color.parse('#FAFAFA Trailing'));
- assert.isNull(Common.Color.Color.parse('#FAFAFG'));
- assert.isNull(Common.Color.Color.parse('gooseberry'));
- assert.isNull(Common.Color.Color.parse('rgb(10% 10% 10% /)'));
- assert.isNull(Common.Color.Color.parse('rgb(10% 10% 10% 0.4 40)'));
- assert.isNull(Common.Color.Color.parse('hsl(0, carrot, 30%)'));
- assert.isNull(Common.Color.Color.parse('hsl(0)'));
- assert.isNull(Common.Color.Color.parse('rgb(255)'));
- assert.isNull(Common.Color.Color.parse('rgba(1 golf 30)'));
+ assert.isNull(Color.Color.parse('#FAFAFA Trailing'));
+ assert.isNull(Color.Color.parse('#FAFAFG'));
+ assert.isNull(Color.Color.parse('gooseberry'));
+ assert.isNull(Color.Color.parse('rgb(10% 10% 10% /)'));
+ assert.isNull(Color.Color.parse('rgb(10% 10% 10% 0.4 40)'));
+ assert.isNull(Color.Color.parse('hsl(0, carrot, 30%)'));
+ assert.isNull(Color.Color.parse('hsl(0)'));
+ assert.isNull(Color.Color.parse('rgb(255)'));
+ assert.isNull(Color.Color.parse('rgba(1 golf 30)'));
});
it('is able to return whether or not the color has an alpha value', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
assert.isTrue(color.hasAlpha(), 'the color should be considered to have an alpha value');
});
it('is able to detect the HEX format of a color with an alpha value', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.detectHEXFormat();
assert.equal(result, 'hexa', 'format was not detected correctly');
});
it('is able to detect the HEX format of a color without an alpha value', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 1], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 1], 'testFormat', 'testColor');
const result = color.detectHEXFormat();
assert.equal(result, 'hex', 'format was not detected correctly');
});
it('is able to return the canonical RGBA of a color', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.canonicalRGBA();
assert.deepEqual(result, [128, 128, 128, 0.5], 'canonical RGBA was not returned correctly');
});
it('is able to return the nickname of a color', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
const result = color.nickname();
assert.equal(result, 'red', 'nickname was not returned correctly');
});
it('returns null as a nickname if the color was not recognized', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.nickname();
assert.isNull(result, 'nickname should be returned as Null');
});
it('is able to convert the color to a protocol RGBA', () => {
- const color = new Common.Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor');
const result = color.toProtocolRGBA();
assert.deepEqual(result, {r: 128, g: 128, b: 128, a: 0.5}, 'conversion to protocol RGBA was not correct');
});
it('is able to invert a color', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
const result = color.invert().rgba();
assert.deepEqual(result, [0, 1, 1, 1], 'inversion was not successful');
});
it('is able to set the alpha value of a color', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'testFormat', 'testColor');
const result = color.setAlpha(0.5).rgba();
assert.deepEqual(result, [1, 0, 0, 0.5], 'alpha value was not set correctly');
});
it('can blend with another color', () => {
- const color = new Common.Color.Color([1, 0, 0, 0.5], 'testFormat', 'testColor');
- const otherColor = new Common.Color.Color([0, 0, 1, 0.5], 'testFormat', 'testColor');
+ const color = new Color.Color([1, 0, 0, 0.5], 'testFormat', 'testColor');
+ const otherColor = new Color.Color([0, 0, 1, 0.5], 'testFormat', 'testColor');
const result = color.blendWith(otherColor).rgba();
assert.deepEqual(result, [0.5, 0, 0.5, 0.75], 'color was not blended correctly');
});
it('returns the original text when turned into a strong if its format was "original"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'original', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'original', 'testColor');
const result = color.asString();
assert.equal(result, 'testColor', 'color was not converted to a string correctly');
});
it('returns the nickname when turned into a strong if its format was "nickname"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'nickname', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'nickname', 'testColor');
const result = color.asString();
assert.equal(result, 'red', 'color was not converted to a string correctly');
});
it('returns the HEX value when turned into a strong if its format was "hex"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'hex', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'hex', 'testColor');
const result = color.asString();
assert.equal(result, '#ff0000', 'color was not converted to a string correctly');
});
it('returns the short HEX value when turned into a strong if its format was "shorthex"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'shorthex', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'shorthex', 'testColor');
const result = color.asString();
assert.equal(result, '#f00', 'color was not converted to a string correctly');
});
it('returns the HEXA value when turned into a strong if its format was "hexa"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'hexa', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'hexa', 'testColor');
const result = color.asString();
assert.equal(result, '#ff0000ff', 'color was not converted to a string correctly');
});
it('returns the short HEXA value when turned into a strong if its format was "shorthexa"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'shorthexa', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'shorthexa', 'testColor');
const result = color.asString();
assert.equal(result, '#f00f', 'color was not converted to a string correctly');
});
it('returns the RGB value when turned into a strong if its format was "rgb"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'rgb', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'rgb', 'testColor');
const result = color.asString();
assert.equal(result, 'rgb(255, 0, 0)', 'color was not converted to a string correctly');
});
it('returns the RGBA value when turned into a strong if its format was "rgba"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'rgba', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'rgba', 'testColor');
const result = color.asString();
assert.equal(result, 'rgba(255, 0, 0, 1)', 'color was not converted to a string correctly');
});
it('returns the HSL value when turned into a strong if its format was "hsl"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'hsl', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'hsl', 'testColor');
const result = color.asString();
assert.equal(result, 'hsl(0, 100%, 50%)', 'color was not converted to a string correctly');
});
it('returns the HSLA value when turned into a strong if its format was "hsla"', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'hsla', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'hsla', 'testColor');
const result = color.asString();
assert.equal(result, 'hsla(0, 100%, 50%, 1)', 'color was not converted to a string correctly');
});
it('is able to return a color in a different format than the one the color was originally set with', () => {
- const color = new Common.Color.Color([1, 0, 0, 1], 'rgb', 'testColor');
+ const color = new Color.Color([1, 0, 0, 1], 'rgb', 'testColor');
const result = color.asString('nickname');
assert.equal(result, 'red', 'color was not converted to a string correctly');
});
@@ -267,13 +267,13 @@
describe('Generator', () => {
it('able to return the color for an ID if the ID was already set', () => {
- const generator = new Common.Color.Generator();
+ const generator = new Color.Generator();
generator.setColorForID('r', 'Red');
assert.equal(generator.colorForID('r'), 'Red', 'color was not retrieved correctly');
});
it('able to return the color for an ID that was not set', () => {
- const generator = new Common.Color.Generator();
+ const generator = new Color.Generator();
assert.equal(generator.colorForID('r'), 'hsla(133, 67%, 80%, 1)', 'color was not generated correctly');
});
});
diff --git a/test/unittests/front_end/karma.conf.js b/test/unittests/front_end/karma.conf.js
new file mode 100644
index 0000000..21bc97d
--- /dev/null
+++ b/test/unittests/front_end/karma.conf.js
@@ -0,0 +1,42 @@
+// Copyright 2019 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.
+
+// @ts-nocheck - we only want TS checking our source files, not JS config like this
+
+// true by default
+// const COVERAGE_ENABLED = !process.env['NOCOVERAGE'];
+
+// false by default
+const DEBUG_ENABLED = !!process.env['DEBUG'];
+
+const browsers = DEBUG_ENABLED ? ['Chrome'] : ['ChromeHeadless'];
+// const reporters = COVERAGE_ENABLED ? ['dots', 'coverage-istanbul'] : ['dots'];
+
+module.exports = function(config) {
+ const options = {
+ basePath: '',
+
+ files: [
+ {pattern: 'test/unittests/**/*_test.js', type: 'module'},
+ {pattern: 'front_end/**/*.js', served: true, included: false},
+ ],
+
+ reporters: ['dots'],
+
+ browsers,
+
+ frameworks: ['mocha', 'chai', 'sinon'],
+
+ plugins: [
+ require('karma-chrome-launcher'),
+ require('karma-mocha'),
+ require('karma-chai'),
+ require('karma-sinon'),
+ ],
+
+ singleRun: !DEBUG_ENABLED
+ };
+
+ config.set(options);
+};
diff --git a/third_party/typescript/ts_library.py b/third_party/typescript/ts_library.py
index f5af5bf..5ed151a 100644
--- a/third_party/typescript/ts_library.py
+++ b/third_party/typescript/ts_library.py
@@ -20,9 +20,10 @@
sys.path = old_sys_path
NODE_LOCATION = devtools_paths.node_path()
-ROOT_TS_CONFIG_LOCATION = path.join(_CURRENT_DIR, '..', '..', 'tsconfig.json')
-
-GLOBAL_DEFS = path.join(_CURRENT_DIR, '..', '..', 'front_end', 'legacy', 'legacy-defs.d.ts')
+ROOT_DIRECTORY_OF_REPOSITORY = path.join(_CURRENT_DIR, '..', '..')
+ROOT_TS_CONFIG_LOCATION = path.join(ROOT_DIRECTORY_OF_REPOSITORY, 'tsconfig.json')
+GLOBAL_DEFS = path.join(ROOT_DIRECTORY_OF_REPOSITORY, 'front_end', 'legacy', 'legacy-defs.d.ts')
+TYPES_NODE_MODULES_DIRECTORY = path.join(ROOT_DIRECTORY_OF_REPOSITORY, 'node_modules', '@types')
RESOURCES_INSPECTOR_PATH = path.join(os.getcwd(), 'resources', 'inspector')
@@ -63,6 +64,7 @@
tsconfig['compilerOptions']['declaration'] = True
tsconfig['compilerOptions']['composite'] = True
tsconfig['compilerOptions']['rootDir'] = get_relative_path_from_output_directory(opts.front_end_directory)
+ tsconfig['compilerOptions']['typeRoots'] = [get_relative_path_from_output_directory(TYPES_NODE_MODULES_DIRECTORY)]
tsconfig['compilerOptions']['outDir'] = '.'
tsconfig['compilerOptions']['tsBuildInfoFile'] = path.basename(tsconfig_output_location) + '.tsbuildinfo'
with open(tsconfig_output_location, 'w') as generated_tsconfig:
diff --git a/third_party/typescript/typescript.gni b/third_party/typescript/typescript.gni
index d5b9f8c..965eef0 100644
--- a/third_party/typescript/typescript.gni
+++ b/third_party/typescript/typescript.gni
@@ -86,10 +86,9 @@
} else if (_extension == "js" || _extension == "ts") {
output_files += [ "$target_gen_dir/$_fileName.js" ]
- _strippedName = string_replace(_fileName, "_bridge", "")
-
# If the stripped name is different, it is a bridge file
- if (_extension == "ts" || _strippedName != _fileName) {
+ if (_extension == "ts" ||
+ string_replace(_fileName, "_bridge", "") != _fileName) {
_front_end_module_name = get_path_info(target_gen_dir, "name")
# Generate JavaScript files are temporarily copied into the old