| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 tests_skipped_++; | 176 tests_skipped_++; |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 tests_run_++; | 182 tests_run_++; |
| 183 | 183 |
| 184 TextRun text_run(input.data(), input.size()); | 184 TextRun text_run(input.data(), input.size()); |
| 185 switch (paragraph_direction) { | 185 switch (paragraph_direction) { |
| 186 case bidi_test::DirectionAutoLTR: | 186 case bidi_test::kDirectionAutoLTR: |
| 187 text_run.SetDirection(DetermineParagraphDirectionality(text_run)); | 187 text_run.SetDirection(DetermineParagraphDirectionality(text_run)); |
| 188 break; | 188 break; |
| 189 case bidi_test::DirectionLTR: | 189 case bidi_test::kDirectionLTR: |
| 190 text_run.SetDirection(TextDirection::kLtr); | 190 text_run.SetDirection(TextDirection::kLtr); |
| 191 break; | 191 break; |
| 192 case bidi_test::DirectionRTL: | 192 case bidi_test::kDirectionRTL: |
| 193 text_run.SetDirection(TextDirection::kRtl); | 193 text_run.SetDirection(TextDirection::kRtl); |
| 194 break; | 194 break; |
| 195 default: | 195 default: |
| 196 break; | 196 break; |
| 197 } | 197 } |
| 198 BidiResolver<TextRunIterator, BidiCharacterRun> resolver; | 198 BidiResolver<TextRunIterator, BidiCharacterRun> resolver; |
| 199 resolver.SetStatus( | 199 resolver.SetStatus( |
| 200 BidiStatus(text_run.Direction(), text_run.DirectionalOverride())); | 200 BidiStatus(text_run.Direction(), text_run.DirectionalOverride())); |
| 201 resolver.SetPositionIgnoringNestedIsolates(TextRunIterator(&text_run, 0)); | 201 resolver.SetPositionIgnoringNestedIsolates(TextRunIterator(&text_run, 0)); |
| 202 | 202 |
| 203 BidiRunList<BidiCharacterRun>& runs = resolver.Runs(); | 203 BidiRunList<BidiCharacterRun>& runs = resolver.Runs(); |
| 204 resolver.CreateBidiRunsForLine(TextRunIterator(&text_run, text_run.length())); | 204 resolver.CreateBidiRunsForLine(TextRunIterator(&text_run, text_run.length())); |
| 205 | 205 |
| 206 std::ostringstream error_context; | 206 std::ostringstream error_context; |
| 207 error_context << ", line " << line_number << " \"" << line << "\""; | 207 error_context << ", line " << line_number << " \"" << line << "\""; |
| 208 error_context << " context: " | 208 error_context << " context: " |
| 209 << bidi_test::nameFromParagraphDirection(paragraph_direction); | 209 << bidi_test::NameFromParagraphDirection(paragraph_direction); |
| 210 | 210 |
| 211 std::vector<int> actual_order; | 211 std::vector<int> actual_order; |
| 212 std::vector<int> actual_levels; | 212 std::vector<int> actual_levels; |
| 213 actual_levels.assign(input.size(), -1); | 213 actual_levels.assign(input.size(), -1); |
| 214 BidiCharacterRun* run = runs.FirstRun(); | 214 BidiCharacterRun* run = runs.FirstRun(); |
| 215 while (run) { | 215 while (run) { |
| 216 // Blink's UBA just makes runs, the actual ordering of the display of | 216 // Blink's UBA just makes runs, the actual ordering of the display of |
| 217 // characters is handled later in our pipeline, so we fake it here: | 217 // characters is handled later in our pipeline, so we fake it here: |
| 218 bool reversed = run->Reversed(false); | 218 bool reversed = run->Reversed(false); |
| 219 DCHECK_GE(run->Stop(), run->Start()); | 219 DCHECK_GE(run->Stop(), run->Start()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // http://www.unicode.org/reports/tr9/#Explicit_Directional_Isolates | 266 // http://www.unicode.org/reports/tr9/#Explicit_Directional_Isolates |
| 267 runner.SkipTestsWith(0x2066); // LRI | 267 runner.SkipTestsWith(0x2066); // LRI |
| 268 runner.SkipTestsWith(0x2067); // RLI | 268 runner.SkipTestsWith(0x2067); // RLI |
| 269 runner.SkipTestsWith(0x2068); // FSI | 269 runner.SkipTestsWith(0x2068); // FSI |
| 270 runner.SkipTestsWith(0x2069); // PDI | 270 runner.SkipTestsWith(0x2069); // PDI |
| 271 | 271 |
| 272 std::string bidi_test_path = "BidiTest.txt"; | 272 std::string bidi_test_path = "BidiTest.txt"; |
| 273 std::ifstream bidi_test_file(bidi_test_path.c_str()); | 273 std::ifstream bidi_test_file(bidi_test_path.c_str()); |
| 274 EXPECT_TRUE(bidi_test_file.is_open()); | 274 EXPECT_TRUE(bidi_test_file.is_open()); |
| 275 bidi_test::Harness<BidiTestRunner> harness(runner); | 275 bidi_test::Harness<BidiTestRunner> harness(runner); |
| 276 harness.parse(bidi_test_file); | 276 harness.Parse(bidi_test_file); |
| 277 bidi_test_file.close(); | 277 bidi_test_file.close(); |
| 278 | 278 |
| 279 if (runner.tests_skipped_) | 279 if (runner.tests_skipped_) |
| 280 LOG(WARNING) << "WARNING: Skipped " << runner.tests_skipped_ << " tests."; | 280 LOG(WARNING) << "WARNING: Skipped " << runner.tests_skipped_ << " tests."; |
| 281 LOG(INFO) << "Ran " << runner.tests_run_ | 281 LOG(INFO) << "Ran " << runner.tests_run_ |
| 282 << " tests: " << runner.level_failures_ << " level failures " | 282 << " tests: " << runner.level_failures_ << " level failures " |
| 283 << runner.order_failures_ << " order failures."; | 283 << runner.order_failures_ << " order failures."; |
| 284 | 284 |
| 285 // The unittest harness only pays attention to GTest output, so we verify | 285 // The unittest harness only pays attention to GTest output, so we verify |
| 286 // that the tests behaved as expected: | 286 // that the tests behaved as expected: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 298 // http://www.unicode.org/reports/tr9/#Explicit_Directional_Isolates | 298 // http://www.unicode.org/reports/tr9/#Explicit_Directional_Isolates |
| 299 runner.SkipTestsWith(0x2066); // LRI | 299 runner.SkipTestsWith(0x2066); // LRI |
| 300 runner.SkipTestsWith(0x2067); // RLI | 300 runner.SkipTestsWith(0x2067); // RLI |
| 301 runner.SkipTestsWith(0x2068); // FSI | 301 runner.SkipTestsWith(0x2068); // FSI |
| 302 runner.SkipTestsWith(0x2069); // PDI | 302 runner.SkipTestsWith(0x2069); // PDI |
| 303 | 303 |
| 304 std::string bidi_test_path = "BidiCharacterTest.txt"; | 304 std::string bidi_test_path = "BidiCharacterTest.txt"; |
| 305 std::ifstream bidi_test_file(bidi_test_path.c_str()); | 305 std::ifstream bidi_test_file(bidi_test_path.c_str()); |
| 306 EXPECT_TRUE(bidi_test_file.is_open()); | 306 EXPECT_TRUE(bidi_test_file.is_open()); |
| 307 bidi_test::CharacterHarness<BidiTestRunner> harness(runner); | 307 bidi_test::CharacterHarness<BidiTestRunner> harness(runner); |
| 308 harness.parse(bidi_test_file); | 308 harness.Parse(bidi_test_file); |
| 309 bidi_test_file.close(); | 309 bidi_test_file.close(); |
| 310 | 310 |
| 311 if (runner.tests_skipped_) | 311 if (runner.tests_skipped_) |
| 312 LOG(WARNING) << "WARNING: Skipped " << runner.tests_skipped_ << " tests."; | 312 LOG(WARNING) << "WARNING: Skipped " << runner.tests_skipped_ << " tests."; |
| 313 LOG(INFO) << "Ran " << runner.tests_run_ | 313 LOG(INFO) << "Ran " << runner.tests_run_ |
| 314 << " tests: " << runner.level_failures_ << " level failures " | 314 << " tests: " << runner.level_failures_ << " level failures " |
| 315 << runner.order_failures_ << " order failures."; | 315 << runner.order_failures_ << " order failures."; |
| 316 | 316 |
| 317 EXPECT_EQ(91660u, runner.tests_run_); | 317 EXPECT_EQ(91660u, runner.tests_run_); |
| 318 EXPECT_EQ(39u, runner.tests_skipped_); | 318 EXPECT_EQ(39u, runner.tests_skipped_); |
| 319 EXPECT_EQ(0u, runner.ignored_char_failures_); | 319 EXPECT_EQ(0u, runner.ignored_char_failures_); |
| 320 EXPECT_EQ(14533u, runner.level_failures_); | 320 EXPECT_EQ(14533u, runner.level_failures_); |
| 321 EXPECT_EQ(14533u, runner.order_failures_); | 321 EXPECT_EQ(14533u, runner.order_failures_); |
| 322 } | 322 } |
| 323 | 323 |
| 324 } // namespace blink | 324 } // namespace blink |
| OLD | NEW |