Class FragmentManager


  • public class FragmentManager
    extends Object
    • Constructor Detail

    • Method Detail

      • usefulFragment

        public static boolean usefulFragment​(Fragment fragment)
        To decide if the fragment is large enough to be a functional entity This is an approximation and can be configured using FragmentRules
        Parameters:
        fragment -
        Returns:
      • getLeafFragments

        public static List<Fragment> getLeafFragments​(List<Fragment> fragments)
        Leaf fragments are fragments that do not have any useful child fragments
        Parameters:
        fragments -
        Returns:
      • setThresholds

        public static void setThresholds​(FragmentRules fragRules)
      • getStateComparisionCache

        public Set<StatePair> getStateComparisionCache()
      • cacheStateComparision

        public void cacheStateComparision​(StatePair statePair,
                                          boolean assignDynamic)
      • setDynamic

        private void setDynamic​(Fragment dyn)
      • setCoverage

        public void setCoverage​(Fragment newFragment)
      • setAccess

        public void setAccess​(Fragment newFragment)
        Used to transfer information regarding already performed actions that can have duplicates in this new-fragment
        Parameters:
        newFragment - a fragment that is being added to the graph
      • addFragment

        public void addFragment​(Fragment fragment,
                                boolean fast)
        Every fragment that is discovered during the crawl will be compared with the global map of unique fragments
        Parameters:
        fragment - the fragment to be added
        fast - if true, the comparison will be done using the fast comparison algorithm
      • updateInfluence

        public void updateInfluence​(Fragment fragment,
                                    FragmentManager.ACCESS access)
        After every action is performed, the priority score or influence is adjusted
        Parameters:
        fragment - the fragment that was just visited
        access - the type of access that was performed
      • recordCoverage

        public boolean recordCoverage​(Node node,
                                      StateVertex state,
                                      VipsUtils.Coverage coverage)
        Can be invoked from a coverage plugin to determine how much of the state DOM is covered by test suites
        Parameters:
        node - the node to be checked
        state - the state to be checked
        coverage - the coverage type
        Returns:
        true if the coverage was recorded, false otherwise
      • recordAccess

        public boolean recordAccess​(CandidateElement element,
                                    StateVertex state)
        Called after a crawl action is performed. Priority of the remaining candidate elements is updated based on their relationship with the action perfomed.
        Parameters:
        element -
        state -
        Returns:
      • setAccess

        public void setAccess​(StateVertex state)
      • getClosestUnexploredState

        public StateVertex getClosestUnexploredState​(StateVertex currentState,
                                                     List<StateVertex> onURLSet,
                                                     BlockingQueue<Integer> statesWithCandidates,
                                                     boolean applyNonSelAdvantage)
        Computes the influences of the states based on the influence of candidates and returns the state that has the highest priority Also takes into consideration the back-tracking effort required to reach the state
        Parameters:
        currentState -
        onURLSet -
        statesWithCandidates -
        applyNonSelAdvantage -
        Returns:
      • calculateCandidateInfluence

        public double calculateCandidateInfluence​(CandidateElement candidate)
      • calculateFragmentCandidateInfluence

        private double calculateFragmentCandidateInfluence​(Fragment fragment)
      • compareImages

        public boolean compareImages​(BufferedImage image1,
                                     BufferedImage image2)
        Color histogram comparison
        Parameters:
        image1 -
        image2 -
        Returns:
      • cacheStateComparision

        public StatePair.StateComparision cacheStateComparision​(StateVertex newState,
                                                                StateVertex expectedState,
                                                                boolean assignDynamic)
        The main function that compares two given states and outputs a classification [clone, near-duplicates (ND-data ND-struct), different]
        Parameters:
        newState -
        expectedState -
        assignDynamic -
        Returns:
      • getAffectedFragments

        private List<Fragment> getAffectedFragments​(List<Node> changedNodes,
                                                    StateVertex state)
        Computes which fragments contain the changed nodes. Changed nodes are the result of DOM differencing between two states being compared.
        Parameters:
        changedNodes -
        state -
        Returns:
      • addToNearDuplicates

        private void addToNearDuplicates​(StateVertex state)
      • hasExploredNearDuplicate

        private boolean hasExploredNearDuplicate​(StateVertex state)
      • addToNearDuplicates

        private void addToNearDuplicates​(StateVertex newState,
                                         StateVertex expectedState)
      • stopCrawling

        public void stopCrawling()
      • cacheStateComparisions

        public void cacheStateComparisions​(StateVertex newState)
      • seenState

        public void seenState​(StateVertex currentState)
        Updates no of times state has not been polled during crawl (Helps prevent crawler getting stuck in similar states)
        Parameters:
        currentState -