OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.distiller; | 5 package org.chromium.distiller; |
6 | 6 |
7 | 7 |
8 public class OpenGraphProtocolParserTest extends DomDistillerJsTestCase { | 8 public class OpenGraphProtocolParserTest extends DomDistillerJsTestCase { |
9 public void testRequiredPropertiesAndDescriptionAndSiteName() { | 9 public void testRequiredPropertiesAndDescriptionAndSiteName() { |
10 String expectedTitle = "Testing required OpenGraph Proptocol properties
and optional Description of the document."; | 10 String expectedTitle = "Testing required OpenGraph Proptocol properties
and optional Description of the document."; |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 427 |
428 // Create the description property with the common "og" prefix, instead | 428 // Create the description property with the common "og" prefix, instead |
429 // of the customized "tstog" prefix. | 429 // of the customized "tstog" prefix. |
430 createMeta("og:description", "this description should be ignored"); | 430 createMeta("og:description", "this description should be ignored"); |
431 | 431 |
432 OpenGraphProtocolParser parser = OpenGraphProtocolParser.parse(mRoot); | 432 OpenGraphProtocolParser parser = OpenGraphProtocolParser.parse(mRoot); |
433 assertNotNull(parser); | 433 assertNotNull(parser); |
434 assertEquals("", parser.getDescription()); | 434 assertEquals("", parser.getDescription()); |
435 } | 435 } |
436 | 436 |
437 @Override | |
438 protected void gwtSetUp() throws Exception { | |
439 super.gwtSetUp(); | |
440 | |
441 // Remove all attributes that specify prefix or namespace, so that each | |
442 // testcase starts with clean HTML and HEAD tags. Otherwise. a testcase | |
443 // may run with the attributes set in a previous testcase, resulting in | |
444 // unexpected results. | |
445 mRoot.removeAttribute("prefix"); | |
446 mRoot.removeAttribute("xmlns:tstog"); | |
447 mRoot.removeAttribute("xmlns:tstpf"); | |
448 mRoot.removeAttribute("xmlns:tsta"); | |
449 } | |
450 | |
451 private void createDefaultTitle() { | 437 private void createDefaultTitle() { |
452 createMeta("og:title", "dummy title"); | 438 createMeta("og:title", "dummy title"); |
453 } | 439 } |
454 | 440 |
455 private void createCustomizedTitle() { | 441 private void createCustomizedTitle() { |
456 createMeta("tstog:title", "dummy title"); | 442 createMeta("tstog:title", "dummy title"); |
457 } | 443 } |
458 | 444 |
459 private void createDefaultType() { | 445 private void createDefaultType() { |
460 createMeta("og:type", "website"); | 446 createMeta("og:type", "website"); |
(...skipping 20 matching lines...) Expand all Loading... |
481 } | 467 } |
482 | 468 |
483 private void createDescription(String description, String prefix) { | 469 private void createDescription(String description, String prefix) { |
484 createMeta(prefix + ":description", description); | 470 createMeta(prefix + ":description", description); |
485 } | 471 } |
486 | 472 |
487 private void createMeta(String property, String content) { | 473 private void createMeta(String property, String content) { |
488 mHead.appendChild(TestUtil.createMetaProperty(property, content)); | 474 mHead.appendChild(TestUtil.createMetaProperty(property, content)); |
489 } | 475 } |
490 } | 476 } |
OLD | NEW |