public void tearDown() throws Exception { Logger.v(TAG, "tearDown()"); // Remove RemoteChatWindowManager of binder mBinder.removeChatWindowManager(mMockRemoteChatWindowManager); mBinder = null; mMockRemoteChatWindowManager = null; mChatWindowManagerAdapters = null; mRemoteChatWindowManager = null; super.tearDown(); }
@Override public void setUp() throws Exception { Logger.v(TAG, "setUp()"); super.setUp(); // Get WindowBinder from ApiService Intent intent = new Intent(getSystemContext(), ApiService.class); intent.setAction(IRemoteWindowBinder.class.getName()); IBinder service = bindService(intent); assertTrue(service.isBinderAlive()); mBinder = (WindowBinder) IRemoteWindowBinder.Stub.asInterface(service); assertNotNull(mBinder); mMockRemoteChatWindowManager = new MockRemoteChatWindowManager(); Field fieldRemoteChatWindowManagers = Utils.getPrivateField(WindowBinder.class, "mChatWindowManagerAdapters"); mChatWindowManagerAdapters = (List<ChatWindowManagerAdapter>) fieldRemoteChatWindowManagers.get(mBinder); // Add RemoteChatWindowManager to binder int startSize = mChatWindowManagerAdapters.size(); mBinder.addChatWindowManager(mMockRemoteChatWindowManager, false); assertEquals(startSize + 1, mChatWindowManagerAdapters.size()); mRemoteChatWindowManager = mChatWindowManagerAdapters.get(0); assertNotNull(mRemoteChatWindowManager); }