list-view.test.js 4.3 KB
Newer Older
雪洛's avatar
雪洛 已提交
1
describe('component-native-list-view', () => {
shutao-dc's avatar
shutao-dc 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  let page
  beforeAll(async () => {
    //打开list-view测试页
    page = await program.reLaunch('/pages/component/list-view/list-view')
    await page.waitFor(600)
  })

  //检测竖向scrolltop属性赋值
  it('check_scroll_top', async () => {
    await page.callMethod('confirm_scroll_top_input', 600)
    await page.waitFor(600)
    const listElement = await page.$('#listview')
    const scrollTop = await listElement.attribute("scrollTop")
    console.log("check_scroll_top---"+scrollTop)
    expect(scrollTop-600).toBeGreaterThanOrEqual(0)
  })

雪洛's avatar
雪洛 已提交
19

lizhongyi_'s avatar
lizhongyi_ 已提交
20
  //检测横向scrollLeft属性赋值 备注:iOS不支持list-view横向滚动
雪洛's avatar
雪洛 已提交
21
  it('check_scroll_left', async () => {
22 23 24 25 26
    if(await page.data('scroll_x_boolean') === false) {
        await page.callMethod('change_scroll_x_boolean', true)
        await page.callMethod('change_scroll_y_boolean', false)
        await page.waitFor(600)
    }
雪洛's avatar
雪洛 已提交
27
    await page.callMethod('confirm_scroll_left_input', 600)
shutao-dc's avatar
shutao-dc 已提交
28 29
    await page.waitFor(600)
    const listElement = await page.$('#listview')
雪洛's avatar
雪洛 已提交
30 31 32
    const scrollLeft = await listElement.attribute("scrollLeft")
    console.log("check_scroll_left---"+scrollLeft)
    expect(scrollLeft-600).toBeGreaterThanOrEqual(0)
shutao-dc's avatar
shutao-dc 已提交
33 34
  })

雪洛's avatar
雪洛 已提交
35 36 37
  if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
    return
  }
lizhongyi_'s avatar
lizhongyi_ 已提交
38 39 40


  if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
lizhongyi_'s avatar
lizhongyi_ 已提交
41 42 43
    return
  }

lizhongyi_'s avatar
lizhongyi_ 已提交
44 45 46 47 48 49 50 51
  //检测竖向可滚动区域
  it('check_scroll_height', async () => {
    await page.callMethod('change_scroll_y_boolean', true)
    await page.callMethod('change_scroll_x_boolean', false)
    await page.waitFor(600)
    const value = await page.callMethod('check_scroll_height')
    expect(value).toBe(true)
  })
lizhongyi_'s avatar
lizhongyi_ 已提交
52

lizhongyi_'s avatar
lizhongyi_ 已提交
53
  //检测横向可滚动区域 备注:iOS不支持list-view横向滚动
shutao-dc's avatar
shutao-dc 已提交
54
  it('check_scroll_width', async () => {
55 56 57 58 59
    if(await page.data('scroll_x_boolean') === false) {
        await page.callMethod('change_scroll_x_boolean', true)
        await page.callMethod('change_scroll_y_boolean', false)
        await page.waitFor(600)
    }
shutao-dc's avatar
shutao-dc 已提交
60 61 62 63 64 65 66
    await page.callMethod('change_scroll_y_boolean', false)
    await page.callMethod('change_scroll_x_boolean', true)
    await page.waitFor(600)
    const value = await page.callMethod('check_scroll_width')
    expect(value).toBe(true)
  })

lizhongyi_'s avatar
lizhongyi_ 已提交
67
  //检测下拉刷新 备注:iOS本地测试结果正确,但是自动化测试结果错误
雪洛's avatar
雪洛 已提交
68
  it('check_refresher', async () => {
69 70 71 72 73
    if(await page.data('scroll_y_boolean') === false) {
        await page.callMethod('change_scroll_y_boolean', true)
        await page.callMethod('change_scroll_x_boolean', false)
        await page.waitFor(600)
    }
雪洛's avatar
雪洛 已提交
74 75 76 77 78 79 80 81
    await page.setData({
        refresher_enabled_boolean: true,
        refresher_triggered_boolean: true
    })
    await page.waitFor(2000)
    expect(await page.data('refresherrefresh')).toBe(true)
  })

lizhongyi_'s avatar
lizhongyi_ 已提交
82
  //检测竖向scroll_into_view属性赋值 备注:iOS本地测试结果正确,但是自动化测试结果错误
雪洛's avatar
雪洛 已提交
83
  it('check_scroll_into_view_top', async () => {
84 85 86 87 88
    if(await page.data('scroll_y_boolean') === false) {
        await page.callMethod('change_scroll_y_boolean', true)
        await page.callMethod('change_scroll_x_boolean', false)
        await page.waitFor(600)
    }
雪洛's avatar
雪洛 已提交
89
    await page.callMethod('item_change_size_enum', 3)
shutao-dc's avatar
shutao-dc 已提交
90 91
    await page.waitFor(600)
    const listElement = await page.$('#listview')
雪洛's avatar
雪洛 已提交
92 93 94 95
    const scrollTop = await listElement.attribute("scrollTop")
    console.log("check_scroll_into_view_top--"+scrollTop)
    await page.callMethod('item_change_size_enum', 0)
    expect(scrollTop-690).toBeGreaterThanOrEqual(0)
shutao-dc's avatar
shutao-dc 已提交
96 97
  })

lizhongyi_'s avatar
lizhongyi_ 已提交
98
  //检测横向scroll_into_view属性赋值 备注:iOS不支持list-view横向滚动
shutao-dc's avatar
shutao-dc 已提交
99
  it('check_scroll_into_view_left', async () => {
100 101 102 103 104
    if(await page.data('scroll_x_boolean') === false) {
        await page.callMethod('change_scroll_x_boolean', true)
        await page.callMethod('change_scroll_y_boolean', false)
        await page.waitFor(600)
    }
shutao-dc's avatar
shutao-dc 已提交
105 106 107 108 109 110 111
    await page.callMethod('item_change_size_enum', 3)
    await page.waitFor(600)
    const listElement = await page.$('#listview')
    const scrollLeft = await listElement.attribute("scrollLeft")
    console.log("check_scroll_into_view_left--"+scrollLeft)
    await page.callMethod('item_change_size_enum', 0)
    expect(scrollLeft-1080).toBeGreaterThanOrEqual(0)
雪洛's avatar
雪洛 已提交
112
  })
shutao-dc's avatar
shutao-dc 已提交
113
})