@@ -10113,6 +10113,7 @@ TEST_F(FeaturesTest, NoNamingStyleViolationsWithPoolOptInIfMessagesAreGood) {
1011310113}
1011410114
1011510115TEST_F(FeaturesTest, VisibilityFeatureSetStrict) {
10116+ pool_.EnforceSymbolVisibility(true);
1011610117 BuildDescriptorMessagesInTestPool();
1011710118
1011810119 ASSERT_THAT(ParseAndBuildFile("vis.proto", R"schema(
@@ -10137,6 +10138,7 @@ TEST_F(FeaturesTest, VisibilityFeatureSetStrict) {
1013710138}
1013810139
1013910140TEST_F(FeaturesTest, VisibilityFeatureSetStrictBadNested) {
10141+ pool_.EnforceSymbolVisibility(true);
1014010142 BuildDescriptorMessagesInTestPool();
1014110143
1014210144 ParseAndBuildFileWithErrorSubstr(
@@ -10157,6 +10159,24 @@ TEST_F(FeaturesTest, VisibilityFeatureSetStrictBadNested) {
1015710159 "in order to be `export`.");
1015810160}
1015910161
10162+ TEST_F(FeaturesTest, VisibilityFeatureSetStrictBadNestedDisabled) {
10163+ pool_.EnforceSymbolVisibility(false);
10164+ BuildDescriptorMessagesInTestPool();
10165+
10166+ EXPECT_THAT(ParseAndBuildFile("vis.proto", R"schema(
10167+ edition = "2024";
10168+ package naming;
10169+
10170+ option features.default_symbol_visibility = STRICT;
10171+
10172+ local message LocalOuter {
10173+ export message Inner {
10174+ }
10175+ }
10176+ )schema"),
10177+ NotNull());
10178+ }
10179+
1016010180TEST_F(FeaturesTest, BadPackageName) {
1016110181 BuildDescriptorMessagesInTestPool();
1016210182
@@ -13188,7 +13208,8 @@ TEST_F(ValidationErrorTest, ExtensionDeclarationsFullNameMissingLeadingDot) {
1318813208}
1318913209
1319013210TEST_F(ValidationErrorTest, VisibilityFromSame) {
13191- ParseAndBuildFile("vis.proto", R"schema(
13211+ pool_.EnforceSymbolVisibility(true);
13212+ EXPECT_THAT(ParseAndBuildFile("vis.proto", R"schema(
1319213213 edition = "2024";
1319313214 package vis.test;
1319413215
@@ -13197,19 +13218,22 @@ TEST_F(ValidationErrorTest, VisibilityFromSame) {
1319713218 export message ExportMessage {
1319813219 LocalMessage foo = 1;
1319913220 }
13200- )schema");
13221+ )schema"),
13222+ NotNull());
1320113223}
1320213224
1320313225TEST_F(ValidationErrorTest, ExplicitVisibilityFromOther) {
13204- ParseAndBuildFile("vis.proto", R"schema(
13226+ pool_.EnforceSymbolVisibility(true);
13227+ ASSERT_THAT(ParseAndBuildFile("vis.proto", R"schema(
1320513228 edition = "2024";
1320613229 package vis.test;
1320713230
1320813231 local message LocalMessage {
1320913232 }
1321013233 export message ExportMessage {
1321113234 }
13212- )schema");
13235+ )schema"),
13236+ NotNull());
1321313237
1321413238 ParseAndBuildFileWithErrorSubstr(
1321513239 "importer.proto",
@@ -13227,25 +13251,53 @@ TEST_F(ValidationErrorTest, ExplicitVisibilityFromOther) {
1322713251 "file\n");
1322813252}
1322913253
13254+ TEST_F(ValidationErrorTest, ExplicitVisibilityFromOtherDisabled) {
13255+ pool_.EnforceSymbolVisibility(false);
13256+ ASSERT_THAT(ParseAndBuildFile("vis.proto", R"schema(
13257+ edition = "2024";
13258+ package vis.test;
13259+
13260+ local message LocalMessage {
13261+ }
13262+ export message ExportMessage {
13263+ }
13264+ )schema"),
13265+ NotNull());
13266+
13267+ EXPECT_THAT(ParseAndBuildFile("importer.proto",
13268+ R"schema(
13269+ edition = "2024";
13270+ import "vis.proto";
13271+
13272+ message BadImport {
13273+ vis.test.LocalMessage foo = 1;
13274+ }
13275+ )schema"),
13276+ NotNull());
13277+ }
13278+
1323013279TEST_F(ValidationErrorTest, Edition2024DefaultVisibilityFromOther) {
13231- ParseAndBuildFile("vis.proto", R"schema(
13280+ pool_.EnforceSymbolVisibility(true);
13281+ ASSERT_THAT(ParseAndBuildFile("vis.proto", R"schema(
1323213282 edition = "2024";
1323313283 package vis.test;
1323413284
1323513285 message TopLevelMessage {
1323613286 message NestedMessage {
1323713287 }
1323813288 }
13239- )schema");
13289+ )schema"),
13290+ NotNull());
1324013291
13241- ParseAndBuildFile("good_importer.proto", R"schema(
13292+ ASSERT_THAT( ParseAndBuildFile("good_importer.proto", R"schema(
1324213293 edition = "2024";
1324313294 import "vis.proto";
1324413295
1324513296 message GoodImport {
1324613297 vis.test.TopLevelMessage foo = 1;
1324713298 }
13248- )schema");
13299+ )schema"),
13300+ NotNull());
1324913301
1325013302 ParseAndBuildFileWithErrorSubstr(
1325113303 "bad_importer.proto", R"schema(
@@ -13265,14 +13317,16 @@ TEST_F(ValidationErrorTest, Edition2024DefaultVisibilityFromOther) {
1326513317}
1326613318
1326713319TEST_F(ValidationErrorTest, VisibilityFromLocalExtender) {
13268- ParseAndBuildFile("vis.proto", R"schema(
13320+ pool_.EnforceSymbolVisibility(true);
13321+ ASSERT_THAT(ParseAndBuildFile("vis.proto", R"schema(
1326913322 edition = "2024";
1327013323 package vis.test;
1327113324
1327213325 local message LocalExtendee {
1327313326 extensions 1 to 100;
1327413327 }
13275- )schema");
13328+ )schema"),
13329+ NotNull());
1327613330
1327713331 ParseAndBuildFileWithErrorSubstr(
1327813332 "bad_importer.proto", R"schema(
0 commit comments