Fix race condition in PointerControllerTest

A previous CL ag/27261516 moved initialisation of thread before the
looper it uses. It introduced a race condition causing tests failures.
This CL changes order of initliation to ensure looper is always
initilised befor the thread.

Bug: 343818855
Test: atest libinputservice_test
Change-Id: Ibcb4d31be6a607f37eeee7207182cdd5eb1d7ead
diff --git a/libs/input/tests/PointerController_test.cpp b/libs/input/tests/PointerController_test.cpp
index cbef68e..5b00fca 100644
--- a/libs/input/tests/PointerController_test.cpp
+++ b/libs/input/tests/PointerController_test.cpp
@@ -162,6 +162,16 @@
 };
 
 class PointerControllerTest : public Test {
+private:
+    void loopThread();
+
+    std::atomic<bool> mRunning = true;
+    class MyLooper : public Looper {
+    public:
+        MyLooper() : Looper(false) {}
+        ~MyLooper() = default;
+    };
+
 protected:
     PointerControllerTest();
     ~PointerControllerTest();
@@ -173,26 +183,16 @@
     std::unique_ptr<MockSpriteController> mSpriteController;
     std::shared_ptr<PointerController> mPointerController;
     sp<android::gui::WindowInfosListener> mRegisteredListener;
+    sp<MyLooper> mLooper;
 
 private:
-    void loopThread();
-
-    std::atomic<bool> mRunning = true;
-    class MyLooper : public Looper {
-    public:
-        MyLooper() : Looper(false) {}
-        ~MyLooper() = default;
-    };
     std::thread mThread;
-
-protected:
-    sp<MyLooper> mLooper;
 };
 
 PointerControllerTest::PointerControllerTest()
       : mPointerSprite(new NiceMock<MockSprite>),
-        mThread(&PointerControllerTest::loopThread, this),
-        mLooper(new MyLooper) {
+        mLooper(new MyLooper),
+        mThread(&PointerControllerTest::loopThread, this) {
     mSpriteController.reset(new NiceMock<MockSpriteController>(mLooper));
     mPolicy = new MockPointerControllerPolicyInterface();