Giter Club home page Giter Club logo

uiautotestsketch's Introduction

大纲

框架概要

思路

阶段一

  1. 以 sketchTree 为标准,假设 sketchTree 中的每个节点都是存在的
  2. 即可以拿 sketchTree 的每个 sketchNode,塞到 nodeTree 中进行查找
  3. 为增加查找速度,每一次的子节点的查找范围,都是建立在“上一次找到的”叔父节点列表

阶段二

  1. 找 codeNode 后的处理

1)新生成的 code 树,返回出来的是代码的结果 2)

/**
 * 问题:怎样定义 “元素存在” 和 “元素偏差” ?
 * - 判断该sketchNode的子节点是否存在
 *
 * *  1) 该sketchNode不存在
 *      - 如果子节点不存在(则可以判断该节点不存在)
 *
 *
 * *  2) 该sketchNode有可能存在,但是样式写错了
 *      - 如果子节点存在(则证明这个sketchNode是存在的,可能是样式偏差)
 *
 */

阶段三

  • 通过 sketch 标示

1. 深度优先遍历 sketchNodeTree 对象

1)处理逻辑

  • 取得的每一个 sketchNode 对象,都塞到 codeTree 进行广度优先查找方法进行查找

  • 如果符合条件的结果,会被推入一个 resultNodeArr 数组,最终,数组会被合并到一个对象里面,如下

 '0': [
    /**
     * "0" 表示sketch节点在第一层,能匹配到两个code的节点
     *   - 查找的codeTree范围是整颗树
    */
    { name: 'div#app', rectAttr: [Object], children: [Array] },
    { name: 'div.main', rectAttr: [Object], children: [Array] }
  ],
  '1': [
    /**
     * “1“ 表示sketch节点在第二层,匹配到的一个code节点
     *   - 查找的codeTree范围是整颗树
     * */
    { name: 'div.footer', rectAttr: [Object], children: [] },
    { name: 'div.body', rectAttr: [Object], children: [] },
    { name: 'div.header', rectAttr: [Object], children: [] }
  ],
  '2': [
    /**
     * “2” 表示sketch节点在第三层,匹配到一个code节点
     *    - 查找的codeTree范围是
    */

    { name: 'div.footer', rectAttr: [Object], children: [] }
    ],
  '3': []

2)结果生成

// sketch.json
{
  "name": "页面 1",
  "rectAttr": { "x": 0, "y": 0, "width": 0, "height": 0 },
  "children": [
    {
      "name": "test1-page",
      "rectAttr": { "x": 493, "y": 270, "width": 375, "height": 667 },
      "children": [
        {
          "name": "footer-container",
          "rectAttr": { "x": 0, "y": 501, "width": 375, "height": 166 },
          "children": [
            {
              "name": "矩形",
              "rectAttr": { "x": 0, "y": 0, "width": 375, "height": 166 },
              "children": []
            }
          ]
        },
        {
          "name": "body-container",
          "rectAttr": { "x": 0, "y": 95, "width": 375, "height": 406 },
          "children": [
            {
              "name": "矩形",
              "rectAttr": { "x": 0, "y": 0, "width": 375, "height": 406 },
              "children": []
            }
          ]
        },
        {
          "name": "header-container",
          "rectAttr": { "x": 0, "y": 0, "width": 375, "height": 95 },
          "children": [
            {
              "name": "矩形",
              "rectAttr": { "x": 0, "y": 0, "width": 375, "height": 95 },
              "children": []
            },
            {
              "name": "Header",
              "rectAttr": { "x": 110.5, "y": 25, "width": 152, "height": 45 },
              "children": []
            }
          ]
        }
      ]
    }
  ]
}
// code.json
{
  "name": "div#app",
  "rectAttr": { "x": 0, "y": 0, "width": 375, "height": 667 },
  "children": [
    {
      "name": "div.main",
      "rectAttr": { "x": 0, "y": 0, "width": 375, "height": 667 },
      "children": [
        {
          "name": "div.header",
          "rectAttr": { "x": 0, "y": 0, "width": 375, "height": 95 },
          "children": []
        },
        {
          "name": "div.body",
          "rectAttr": { "x": 0, "y": 95, "width": 375, "height": 406 },
          "children": []
        },
        {
          "name": "div.footer",
          "rectAttr": { "x": 0, "y": 501, "width": 375, "height": 166 },
          "children": []
        }
      ]
    }
  ]
}

uiautotestsketch's People

Stargazers

 avatar

Watchers

Williamyorkl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.