CTS问题的处理

CTS问题的处理

流程

   为了更好的描述处理这类问题的流程,下面将以以下两个例子为例,进行描述:

例子1:【GMS认证】【CTS_instant】CtsTextTestCases–android.text.cts.MyanmarTest#testCompositionSemantics
例子2:【STS】【CtsSecurityTestCases】android.security.cts.StagefrightTest#testStagefright_bug_62673179

1. 确定问题所属的模块

   首先遇到这些问题时,要先确定好是哪些模块导致的。

   确定模块的方式有两个:

  1. 根据经验判断,如例子1,看到CtsTextTestCases这个模块的测试,就会想到字体或者布局相关的模块。
  2. 根据源码的调用情况:以例子1为例,通过在openGrok上搜索用例的关键词,找到其所在的源码:

40    public void testCompositionSemantics() {
41        Context context = InstrumentationRegistry.getTargetContext();
42        String textA = "\u1019\u102d\u102f";
43        String textB = "\u1019\u102f\u102d"; // wrong order for Unicode
44
45        CaptureTextView cviewA = new CaptureTextView(context);
46        Bitmap bitmapA = cviewA.capture(textA);
47        CaptureTextView cviewB = new CaptureTextView(context);
48        Bitmap bitmapB = cviewB.capture(textB);
49        if (bitmapA.sameAs(bitmapB)) {
50            // if textA and textB render identically, test against replacement characters
51            String textC = "\ufffd\ufffd\ufffd"; // replacement characters are acceptable
52            CaptureTextView cviewC = new CaptureTextView(context);
53            Bitmap bitmapC = cviewC.capture(textC);
54            if (!bitmapA.sameAs(bitmapC)) {
55                // ...or against blank/empty glyphs
56                Bitmap bitmapD = Bitmap.createBitmap(bitmapC.getWidth(), bitmapC.getHeight(),
57                        bitmapC.getConfig());
58                assertTrue(bitmapA.sameAs(bitmapD));
59            }
60        }
61    }

   可以看到这个用例是,对比字符样式的需求,所以可以确定可能是属于共库控件或者字体相关的模块。

2. 确定该问题是否我们处理

   首先,要确认的是,会出现cts问题(包含sts),正常情况原因如下:

  1. 谷歌分发出来的补丁没有修复,如例子2;
  2. 对于系统的定制导致代码逻辑出现问题,如例子1。

3.解决途径

   一般解决这类问题的思路有如下:

  1. 先在Bug平台上面搜索是否有相关问题,如果有的话,可能这个问题就是某些代码没有提交或者流入固件分支,可以通过查看代码提交记录来处理这个问题。

  2. 如果在Bug平台上搜不到相关的问题,则需要定位问题的位置。

   针对上述的两种问题的处理方式有如下:

   对于补丁未修复的问题,以例子2为例,需要去谷歌安全论坛上,找到对应未修复的补丁,可以通过搜索bugID来查找,找到后修复即可。

CTS问题的处理_第1张图片

   对于代码逻辑导致的问题,以例子1为例,则需要结合log以及用例源码来分析,有时候也可能需要反编译cts测试包查看相关逻辑。


40    public void testCompositionSemantics() {
41        Context context = InstrumentationRegistry.getTargetContext();
42        String textA = "\u1019\u102d\u102f";
43        String textB = "\u1019\u102f\u102d"; // wrong order for Unicode
44
45        CaptureTextView cviewA = new CaptureTextView(context);
46        Bitmap bitmapA = cviewA.capture(textA);
47        CaptureTextView cviewB = new CaptureTextView(context);
48        Bitmap bitmapB = cviewB.capture(textB);
49        if (bitmapA.sameAs(bitmapB)) {
50            // if textA and textB render identically, test against replacement characters
51            String textC = "\ufffd\ufffd\ufffd"; // replacement characters are acceptable
52            CaptureTextView cviewC = new CaptureTextView(context);
53            Bitmap bitmapC = cviewC.capture(textC);
54            if (!bitmapA.sameAs(bitmapC)) {
55                // ...or against blank/empty glyphs
56                Bitmap bitmapD = Bitmap.createBitmap(bitmapC.getWidth(), bitmapC.getHeight(),
57                        bitmapC.getConfig());
58                assertTrue(bitmapA.sameAs(bitmapD));
59            }
60        }
61    }

   其中,log可以定位出在用例的哪个位置出现了异常。如例子1:

CTS问题的处理_第2张图片

   这里可以看出,系统通过对比字符的样式,如果有异常,就会抛出断言异常,据此就知道是字体导致这类问题,从而去字体相关模块排查问题。

4. 问题修复

   问题修复后,可以编一个freestyle在本地跑下cts,sts测试相关问题,看能否通过,通过后合入对应的机型分支。

你可能感兴趣的:(android)