Move rtc_json code from API dir, enable unit test, unmark testonly
This change does three things:
- Move rtc_json into rtc_base/strings/, a non-API directory more fitting to
its purpose.
- Make a target for the currently unused json_unittest.
- Make the code available for use in non-test code again.
Bug: webrtc:9802
Change-Id: Id964a8a4b47b732a962a364894a4dbd3e7f4650f
Reviewed-on: https://webrtc-review.googlesource.com/103126
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24932}
diff --git a/BUILD.gn b/BUILD.gn
index b1fc7b4..85b0769 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -465,6 +465,7 @@
"rtc_base:rtc_base_tests_main",
"rtc_base:rtc_base_tests_utils",
"rtc_base:rtc_base_unittests",
+ "rtc_base:rtc_json_unittests",
"rtc_base:rtc_numerics_unittests",
"rtc_base:rtc_task_queue_unittests",
"rtc_base:sequenced_task_checker_unittests",
diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc
index 65d4aca..c25259c 100644
--- a/examples/peerconnection/client/conductor.cc
+++ b/examples/peerconnection/client/conductor.cc
@@ -24,8 +24,8 @@
#include "modules/audio_processing/include/audio_processing.h"
#include "modules/video_capture/video_capture_factory.h"
#include "rtc_base/checks.h"
-#include "rtc_base/json.h"
#include "rtc_base/logging.h"
+#include "rtc_base/strings/json.h"
// Names used for a IceCandidate JSON object.
const char kCandidateSdpMidName[] = "sdpMid";
diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc
index 4ac92ee..f7333cb 100644
--- a/modules/audio_processing/test/audio_processing_simulator.cc
+++ b/modules/audio_processing/test/audio_processing_simulator.cc
@@ -24,8 +24,8 @@
#include "modules/audio_processing/include/audio_processing.h"
#include "modules/audio_processing/test/fake_recording_device.h"
#include "rtc_base/checks.h"
-#include "rtc_base/json.h"
#include "rtc_base/logging.h"
+#include "rtc_base/strings/json.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/stringutils.h"
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 8dc98b6..e9efbd1 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -683,11 +683,10 @@
}
rtc_source_set("rtc_json") {
- testonly = true
defines = []
sources = [
- "json.cc",
- "json.h",
+ "strings/json.cc",
+ "strings/json.h",
]
deps = [
":stringutils",
@@ -1264,6 +1263,20 @@
]
}
+ rtc_source_set("rtc_json_unittests") {
+ testonly = true
+
+ sources = [
+ "strings/json_unittest.cc",
+ ]
+ deps = [
+ ":rtc_base_tests_main",
+ ":rtc_base_tests_utils",
+ ":rtc_json",
+ "../test:test_support",
+ ]
+ }
+
rtc_source_set("rtc_base_unittests") {
testonly = true
defines = []
diff --git a/rtc_base/json.cc b/rtc_base/strings/json.cc
similarity index 99%
rename from rtc_base/json.cc
rename to rtc_base/strings/json.cc
index f7716ab..efcb97a 100644
--- a/rtc_base/json.cc
+++ b/rtc_base/strings/json.cc
@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "rtc_base/json.h"
+#include "rtc_base/strings/json.h"
#include <errno.h>
#include <limits.h>
diff --git a/rtc_base/json.h b/rtc_base/strings/json.h
similarity index 96%
rename from rtc_base/json.h
rename to rtc_base/strings/json.h
index b8e6d95..0cb9542 100644
--- a/rtc_base/json.h
+++ b/rtc_base/strings/json.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef RTC_BASE_JSON_H_
-#define RTC_BASE_JSON_H_
+#ifndef RTC_BASE_STRINGS_JSON_H_
+#define RTC_BASE_STRINGS_JSON_H_
#include <string>
#include <vector>
@@ -85,4 +85,4 @@
} // namespace rtc
-#endif // RTC_BASE_JSON_H_
+#endif // RTC_BASE_STRINGS_JSON_H_
diff --git a/rtc_base/json_unittest.cc b/rtc_base/strings/json_unittest.cc
similarity index 98%
rename from rtc_base/json_unittest.cc
rename to rtc_base/strings/json_unittest.cc
index 17b126a..2215769 100644
--- a/rtc_base/json_unittest.cc
+++ b/rtc_base/strings/json_unittest.cc
@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "rtc_base/json.h"
+#include "rtc_base/strings/json.h"
#include <vector>
@@ -88,7 +88,7 @@
EXPECT_TRUE(GetUIntFromJson(big_u, &out));
EXPECT_EQ(0xFFFFFFFFU, out);
EXPECT_FALSE(GetUIntFromJson(in_s, &out));
- // TODO: Fail reading negative strings.
+ // TODO(bugs.webrtc.org/9804): Fail reading negative strings.
// EXPECT_FALSE(GetUIntFromJson(in_si, &out));
EXPECT_FALSE(GetUIntFromJson(in_i, &out));
EXPECT_FALSE(GetUIntFromJson(big_sn, &out));
diff --git a/stats/rtcstats_unittest.cc b/stats/rtcstats_unittest.cc
index de3e18c..349d40c 100644
--- a/stats/rtcstats_unittest.cc
+++ b/stats/rtcstats_unittest.cc
@@ -15,7 +15,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/json.h"
+#include "rtc_base/strings/json.h"
#include "stats/test/rtcteststats.h"
namespace webrtc {
diff --git a/video/replay.cc b/video/replay.cc
index 10aec6f..5c17e5b 100644
--- a/video/replay.cc
+++ b/video/replay.cc
@@ -24,8 +24,8 @@
#include "rtc_base/checks.h"
#include "rtc_base/file.h"
#include "rtc_base/flags.h"
-#include "rtc_base/json.h"
#include "rtc_base/string_to_number.h"
+#include "rtc_base/strings/json.h"
#include "rtc_base/timeutils.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/sleep.h"