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 19 20 21 22 23 24 25 26 27
  let page
  beforeAll(async () => {
    //打开list-view测试页
    page = await program.reLaunch('/pages/component/list-view/list-view')
    await page.waitFor(600)
  })

  //检测竖向可滚动区域
  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)
  })

  //检测竖向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
雪洛 已提交
28

lizhongyi_'s avatar
lizhongyi_ 已提交
29
  //检测横向scrollLeft属性赋值 备注:iOS不支持list-view横向滚动
雪洛's avatar
雪洛 已提交
30
  it('check_scroll_left', async () => {
31 32 33 34 35
    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
雪洛 已提交
36
    await page.callMethod('confirm_scroll_left_input', 600)
shutao-dc's avatar
shutao-dc 已提交
37 38
    await page.waitFor(600)
    const listElement = await page.$('#listview')
雪洛's avatar
雪洛 已提交
39 40 41
    const scrollLeft = await listElement.attribute("scrollLeft")
    console.log("check_scroll_left---"+scrollLeft)
    expect(scrollLeft-600).toBeGreaterThanOrEqual(0)
shutao-dc's avatar
shutao-dc 已提交
42 43
  })

雪洛's avatar
雪洛 已提交
44 45 46
  if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
    return
  }
shutao-dc's avatar
shutao-dc 已提交
47

lizhongyi_'s avatar
lizhongyi_ 已提交
48 49 50 51 52
  if (process.env.uniTestPlatformInfo.indexOf('iOS') > -1) {
    return
  }

  //检测横向可滚动区域 备注:iOS不支持list-view横向滚动
shutao-dc's avatar
shutao-dc 已提交
53
  it('check_scroll_width', async () => {
54 55 56 57 58
    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 已提交
59 60 61 62 63 64 65
    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_ 已提交
66
  //检测下拉刷新 备注:iOS本地测试结果正确,但是自动化测试结果错误
雪洛's avatar
雪洛 已提交
67
  it('check_refresher', async () => {
68 69 70 71 72
    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
雪洛 已提交
73 74 75 76 77 78 79 80
    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_ 已提交
81
  //检测竖向scroll_into_view属性赋值 备注:iOS本地测试结果正确,但是自动化测试结果错误
雪洛's avatar
雪洛 已提交
82
  it('check_scroll_into_view_top', async () => {
83 84 85 86 87
    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
雪洛 已提交
88
    await page.callMethod('item_change_size_enum', 3)
shutao-dc's avatar
shutao-dc 已提交
89 90
    await page.waitFor(600)
    const listElement = await page.$('#listview')
雪洛's avatar
雪洛 已提交
91 92 93 94
    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 已提交
95 96
  })

lizhongyi_'s avatar
lizhongyi_ 已提交
97
  //检测横向scroll_into_view属性赋值 备注:iOS不支持list-view横向滚动
shutao-dc's avatar
shutao-dc 已提交
98
  it('check_scroll_into_view_left', async () => {
99 100 101 102 103
    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 已提交
104 105 106 107 108 109 110
    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
雪洛 已提交
111
  })
shutao-dc's avatar
shutao-dc 已提交
112
})