\brief Generates a restriction section, adds it to an empty mwm, loads the restriction section and test loaded restrictions. \param |restrictionPath| comma separated text with restrictions in osm id terms. \param |osmIdsToFeatureIdContent| comma separated text with mapping from osm ids to feature ids.
| 135 | /// \param |restrictionPath| comma separated text with restrictions in osm id terms. |
| 136 | /// \param |osmIdsToFeatureIdContent| comma separated text with mapping from osm ids to feature ids. |
| 137 | void TestRestrictionBuilding(string const & restrictionPath, string const & osmIdsToFeatureIdContent, |
| 138 | unique_ptr<IndexGraph> graph, vector<Restriction> & expectedNotUTurn, |
| 139 | vector<RestrictionUTurnForTests> & expectedUTurn) |
| 140 | { |
| 141 | Platform & platform = GetPlatform(); |
| 142 | string const writableDir = platform.WritableDir(); |
| 143 | |
| 144 | string const targetDir = base::JoinPath(writableDir, kTestDir); |
| 145 | // Building empty mwm. |
| 146 | LocalCountryFile country(targetDir, CountryFile(kTestMwm), 0 /* version */); |
| 147 | ScopedDir const scopedDir(kTestDir); |
| 148 | string const mwmRelativePath = base::JoinPath(kTestDir, kTestMwm + DATA_FILE_EXTENSION); |
| 149 | ScopedFile const scopedMwm(mwmRelativePath, ScopedFile::Mode::Create); |
| 150 | BuildEmptyMwm(country); |
| 151 | |
| 152 | // Creating a file with restrictions. |
| 153 | string const restrictionRelativePath = base::JoinPath(kTestDir, kRestrictionFileName); |
| 154 | ScopedFile const restrictionScopedFile(restrictionRelativePath, restrictionPath); |
| 155 | |
| 156 | // Creating osm ids to feature ids mapping. |
| 157 | string const mappingRelativePath = base::JoinPath(kTestDir, kOsmIdsToFeatureIdsName); |
| 158 | ScopedFile const mappingFile(mappingRelativePath, ScopedFile::Mode::Create); |
| 159 | string const & osmIdsToFeatureIdFullPath = mappingFile.GetFullPath(); |
| 160 | ReEncodeOsmIdsToFeatureIdsMapping(osmIdsToFeatureIdContent, osmIdsToFeatureIdFullPath); |
| 161 | |
| 162 | string const restrictionFullPath = base::JoinPath(writableDir, restrictionRelativePath); |
| 163 | string const & mwmFullPath = scopedMwm.GetFullPath(); |
| 164 | |
| 165 | // Prepare data to collector. |
| 166 | auto restrictionCollector = |
| 167 | std::make_unique<routing_builder::RestrictionCollector>(osmIdsToFeatureIdFullPath, *graph); |
| 168 | |
| 169 | TEST(restrictionCollector->Process(restrictionFullPath), ("Bad restrictions were given.")); |
| 170 | |
| 171 | // Adding restriction section to mwm. |
| 172 | SerializeRestrictions(*restrictionCollector, mwmFullPath); |
| 173 | |
| 174 | // Reading from mwm section and testing restrictions. |
| 175 | vector<Restriction> restrictionsFromMwm; |
| 176 | vector<RestrictionUTurnForTests> restrictionsUTurnFromMwm; |
| 177 | LoadRestrictions(mwmFullPath, restrictionsFromMwm, restrictionsUTurnFromMwm); |
| 178 | |
| 179 | sort(restrictionsFromMwm.begin(), restrictionsFromMwm.end()); |
| 180 | sort(restrictionsUTurnFromMwm.begin(), restrictionsUTurnFromMwm.end()); |
| 181 | |
| 182 | sort(expectedNotUTurn.begin(), expectedNotUTurn.end()); |
| 183 | sort(expectedUTurn.begin(), expectedUTurn.end()); |
| 184 | |
| 185 | TEST_EQUAL(restrictionsFromMwm, expectedNotUTurn, ()); |
| 186 | TEST_EQUAL(restrictionsUTurnFromMwm, expectedUTurn, ()); |
| 187 | } |
| 188 | |
| 189 | // 2 * |
| 190 | // ↗ ↘ |
no test coverage detected