Myhera_L 2024-11-06 17:56 采纳率: 0%
浏览 0
问题最晚将于11月14日00:00点结题

Wanted but not invoked:Actually, there were zero interactions with this moc


    fun testDiscoverDkGattService() {

        // 2. Advertise the host's (presumably the car's) Bluetooth capabilities using another
        //    gRPC call:
        // - `hostBlocking()` accesses another gRPC service related to the host.
        //   The following `advertise(...)` sends an advertise request to the server, setting
        //   specific attributes.
        mBumble
            .hostBlocking()
            .advertise(
                AdvertiseRequest.newBuilder()
                    .setLegacy(
                        true
                    ) // As of now, Bumble only support legacy advertising (b/266124496).
                    .setConnectable(true)
                    .setOwnAddressType(
                        OwnAddressType.RANDOM
                    ) // Ask Bumble to advertise it's `RANDOM` address.
                    .build()
            )

        // 3. Fetch a remote Bluetooth device instance (here, Bumble).
        val bumbleDevice =
            bluetoothAdapter.getRemoteLeDevice(
                // To keep things straightforward, the Bumble RANDOM address is set to a predefined
                // constant.
                // Typically, an LE scan would be conducted to identify the Bumble device, matching
                // it based on its
                // Advertising data.
                Utils.BUMBLE_RANDOM_ADDRESS,
                BluetoothDevice
                    .ADDRESS_TYPE_RANDOM // Specify address type as RANDOM because the device
                // advertises with this address type.
            )

        // 4. Create a mock callback to handle Bluetooth GATT (Generic Attribute Profile) related
        // events.
        val gattCallback = mock<BluetoothGattCallback>()

        // 5. Connect to the Bumble device and expect a successful connection callback.
        var bumbleGatt = bumbleDevice.connectGatt(context, false, gattCallback)
        verify(gattCallback, timeout(TIMEOUT))
            .onConnectionStateChange(
                any(),
                eq(BluetoothGatt.GATT_SUCCESS),
                eq(BluetoothProfile.STATE_CONNECTED)
            )

        // 6. Discover GATT services offered by Bumble and expect successful service discovery.
        bumbleGatt.discoverServices()
        verify(gattCallback, timeout(DISCOVERY_TIMEOUT))
            .onServicesDiscovered(any(), eq(BluetoothGatt.GATT_SUCCESS))

        // 7. Check if the required service (CCC_DK_UUID) is available on Bumble.
        assertThat(bumbleGatt.getService(CCC_DK_UUID)).isNotNull()

        // 8. Disconnect from the Bumble device and expect a successful disconnection callback.
        bumbleGatt.disconnect()
        verify(gattCallback, timeout(TIMEOUT))
            .onConnectionStateChange(
                any(),
                eq(BluetoothGatt.GATT_SUCCESS),
                eq(BluetoothProfile.STATE_DISCONNECTED)
            )
    }

上面是谷歌源码,本地代码这一块和谷歌是一样的,但是运行时,会报下面的错误
2024-10-08 17:40:52 atest_tf_test_runner.py:512:DEBUG: received: TEST_FAILED
{"trace":"Wanted but not invoked:\r\nbluetoothGattCallback.onConnectionStateChange(\r\n
,\r\n 0,\r\n 2\r\n);\r\n-> at android.bluetooth.DckGattTest.testDiscoverDkGattService(DckGattTest.kt:193)\r\nActually,
there were zero interactions with this mock.
\r\n\r\n\tat android.bluetooth.DckGattTest.testDiscoverDkGattService(DckGattTest.kt:193)\r\n",
"action_in_progress":"UNSET","className":"android.bluetooth.DckGattTest","testName":"testDiscoverDkGattService[connected=false]"}
有知道是缺少什么文件吗?

  • 写回答

17条回答 默认 最新

  • 专家-皆知 2024-11-06 17:57
    关注

    以下回复引自免费微信小程序:皆我百晓生。 如问题解决,还请采纳。如仍有疑问,请回复留言或私信博主,以便获得更精准的帮助。

    问题是“JAVA、KOTLIN和ANDROID是否有与这个MOC(MOBILE OBJECT MODEL)的交互?”

    解决方案是:“没有”,因为没有提到JAVA、KOTLIN或ANDROID中有任何与MOC相关的交互。这可能是因为MOC是一个开放源码框架,它允许开发者使用多种语言来开发应用程序,包括JAVA、KOTLIN和ANDROID等。因此,这些语言中的任何一个都可能是与MOC相关的。

    评论

报告相同问题?

问题事件

  • 创建了问题 11月6日

悬赏问题

  • ¥66 换电脑后应用程序报错
  • ¥50 array数据同步问题
  • ¥15 pic16F877a单片机的外部触发中断程序仿真失效
  • ¥15 Matlab插值拟合差分微分规划图论
  • ¥15 keil5 target not created
  • ¥15 C/C++数据与算法请教
  • ¥15 怎么找志同道合的伙伴
  • ¥20 如何让程序ab.eXe自已删除干净硬盘里的本文件自己的ab.eXe文件
  • ¥50 爬虫预算充足,跪巨佬
  • ¥15 滑块验证码拖动问题悬赏