Commit de8f7f75 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Unittest added to Network Traffic Annotation Auditor.

Network traffic annotation auditor have no test support. A unittest is added to
cover some tests.

Bug: 656607
Bug: 690323
Change-Id: I93b05cf7ec4d89fca07166b230a4fc314fc438e7
Reviewed-on: https://chromium-review.googlesource.com/519244
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485225}
parent 96ca7166
...@@ -149,6 +149,7 @@ group("gn_all") { ...@@ -149,6 +149,7 @@ group("gn_all") {
"//tools/gn:gn_unittests", "//tools/gn:gn_unittests",
"//tools/perf/clear_system_cache", "//tools/perf/clear_system_cache",
"//tools/traffic_annotation/auditor:traffic_annotation_auditor", "//tools/traffic_annotation/auditor:traffic_annotation_auditor",
"//tools/traffic_annotation/auditor:traffic_annotation_auditor_unittests",
"//ui/accessibility:accessibility_unittests", "//ui/accessibility:accessibility_unittests",
"//ui/accessibility/extensions", "//ui/accessibility/extensions",
] ]
......
...@@ -4138,6 +4138,12 @@ ...@@ -4138,6 +4138,12 @@
}, },
"test": "sync_integration_tests" "test": "sync_integration_tests"
}, },
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "traffic_annotation_auditor_unittests"
},
{ {
"swarming": { "swarming": {
"can_use_on_swarming_builders": true "can_use_on_swarming_builders": true
......
...@@ -941,6 +941,11 @@ ...@@ -941,6 +941,11 @@
"../../", "../../",
], ],
}, },
"traffic_annotation_auditor_unittests": {
"label":
"//tools/traffic_annotation/auditor:traffic_annotation_auditor_unittests",
"type": "console_test_launcher",
},
"cc_perftests": { "cc_perftests": {
"label": "//cc:cc_perftests", "label": "//cc:cc_perftests",
"type": "script", "type": "script",
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# 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.
import("//testing/test.gni")
import("//third_party/protobuf/proto_library.gni") import("//third_party/protobuf/proto_library.gni")
# Works only on desktop platforms. # Works only on desktop platforms.
...@@ -41,20 +42,43 @@ proto_library("traffic_annotation") { ...@@ -41,20 +42,43 @@ proto_library("traffic_annotation") {
use_protobuf_full = true use_protobuf_full = true
} }
executable("traffic_annotation_auditor") { source_set("auditor_sources") {
sources = [ sources = [
"../../../net/traffic_annotation/network_traffic_annotation.h", "../../../net/traffic_annotation/network_traffic_annotation.h",
"../../../net/traffic_annotation/network_traffic_annotation_test_helper.h", "../../../net/traffic_annotation/network_traffic_annotation_test_helper.h",
"traffic_annotation_auditor.cc", "traffic_annotation_auditor.cc",
"traffic_annotation_auditor.h", "traffic_annotation_auditor.h",
"traffic_annotation_auditor_ui.cc",
"traffic_annotation_file_filter.cc", "traffic_annotation_file_filter.cc",
"traffic_annotation_file_filter.h", "traffic_annotation_file_filter.h",
] ]
deps = [ public_deps = [
":traffic_annotation", ":traffic_annotation",
"//base", "//base",
"//net:traffic_annotation",
"//third_party/protobuf:protobuf_full", "//third_party/protobuf:protobuf_full",
] ]
} }
executable("traffic_annotation_auditor") {
sources = [
"traffic_annotation_auditor_ui.cc",
]
deps = [
":auditor_sources",
]
}
test("traffic_annotation_auditor_unittests") {
sources = [
"traffic_annotation_auditor_unittest.cc",
]
deps = [
":auditor_sources",
"//base/test:run_all_unittests",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
]
}
// Copyright 2017 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 "tools/traffic_annotation/auditor/traffic_annotation_auditor.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
#define TEST_HASH_CODE(X) \
EXPECT_EQ(TrafficAnnotationAuditor::ComputeHashValue(X), \
net::DefineNetworkTrafficAnnotation(X, "").unique_id_hash_code)
}
using namespace testing;
typedef ::testing::Test TrafficAnnotationAuditorTest;
// Tests if the two hash computation functions have the same result.
TEST_F(TrafficAnnotationAuditorTest, HashFunctionCheck) {
TEST_HASH_CODE("test");
TEST_HASH_CODE("unique_id");
TEST_HASH_CODE("123_id");
TEST_HASH_CODE("ID123");
TEST_HASH_CODE(
"a_unique_looooooooooooooooooooooooooooooooooooooooooooooooooooooong_id");
}
\ No newline at end of file
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