/*
 * Tanaguru - Automated webpage assessment
 * Copyright (C) 2008-2015  Tanaguru.org
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contact us by mail: tanaguru AT tanaguru DOT org
 */

package org.tanaguru.rules.rgaa30;

import org.tanaguru.ruleimplementation.AbstractPageRuleWithSelectorAndCheckerImplementation;
import org.tanaguru.rules.elementchecker.pertinence.TextPertinenceChecker;
import org.tanaguru.rules.elementselector.ElementSelector;
import org.tanaguru.rules.elementselector.SimpleElementSelector;
import static org.tanaguru.rules.keystore.HtmlElementStore.TEXT_ELEMENT2;
import static org.tanaguru.rules.keystore.HtmlElementStore.TITLE_ELEMENT;
import static org.tanaguru.rules.keystore.RemarkMessageStore.CHECK_TITLE_PERTINENCE_MSG;
import static org.tanaguru.rules.keystore.RemarkMessageStore.NOT_PERTINENT_TITLE_MSG;

/**
 * Implementation of the rule 8.6.1 of the referential Accessiweb 4.1.
 * <br/>
 * For more details about the implementation, refer to <a href="http://tanaguru-rules-rgaa3.readthedocs.org/en/latest/Rule-8-6-1">the rule 8.6.1 design page.</a>
 * @see <a href="http://references.modernisation.gouv.fr/sites/default/files/RGAA3_RC2-1/referentiel_technique.htm#test-8-6-2"> 8.6.1 rule specification</a>
 *
 */
public class Rgaa30Rule080601 extends AbstractPageRuleWithSelectorAndCheckerImplementation {

    /* The selector */
    private static final ElementSelector ELEMENT_SELECTOR = 
            new SimpleElementSelector(TITLE_ELEMENT);
    
    /* Title blacklisted nomenclature */
    private static final String TITLE_BLACKLIST_NOM = "UnexplicitPageTitle";
    
    /**
     * Default constructor
     */
    public Rgaa30Rule080601 () {
        super(
                ELEMENT_SELECTOR,
                new TextPertinenceChecker(
                    // check emptiness
                    true, 
                    // no comparison with other attribute
                    null, 
                    // blacklist nomenclature name
                    TITLE_BLACKLIST_NOM, 
                    // not pertinent message
                    NOT_PERTINENT_TITLE_MSG, 
                    // manual check message
                    CHECK_TITLE_PERTINENCE_MSG,
                    // evidence elements
                    TEXT_ELEMENT2
                )
            );
    }

}

@@ -1018,67 +1018,8 @@
 er;%0A
-import org.tanaguru.rules.elementselector.ElementSelector;%0A
 impo
@@ -1125,38 +1125,58 @@
 ore.
-HtmlElementStore.TEXT_ELEMENT2
+CssLikeQueryStore.TITLE_WITHIN_HEAD_CSS_LIKE_QUERY
 ;%0Aim
@@ -1233,28 +1233,27 @@
 tStore.T
-ITLE
+EXT
 _ELEMENT
 ;%0Aimport
@@ -1244,16 +1244,17 @@
 _ELEMENT
+2
 ;%0Aimport
@@ -1931,151 +1931,8 @@
  %7B%0A%0A
-    /* The selector */%0A    private static final ElementSelector ELEMENT_SELECTOR = %0A            new SimpleElementSelector(TITLE_ELEMENT);%0A    %0A
     
@@ -2161,24 +2161,67 @@
     
-ELEMENT_SELECTOR
+new SimpleElementSelector(TITLE_WITHIN_HEAD_CSS_LIKE_QUERY)
 ,%0A  

update 8.6.1 : only test title tag within head tag