1 /* 2 * Copyright (C) 2016, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <gtest/gtest.h> 18 19 #include "wificond/ipc_constants.h" 20 #include "wificond/tests/shell_utils.h" 21 #include "wificond/tests/integration/process_utils.h" 22 23 using android::wificond::ipc_constants::kServiceName; 24 using android::wificond::tests::integration::RunShellCommand; 25 using android::wificond::tests::integration::WaitForTrue; 26 using android::wificond::tests::integration::IsBinderServiceRegistered; 27 using android::wificond::tests::integration::ScopedDevModeWificond; 28 using android::wificond::tests::integration::WificondIsRunning; 29 using android::wificond::tests::integration::WificondIsDead; 30 using android::wificond::tests::integration::WificondSetDevMode; 31 32 namespace android { 33 namespace wificond { 34 35 TEST(LifeCycleTest, ProcessStartsUp) { 36 // Request that wificond be stopped (regardless of its current state). 37 RunShellCommand("stop wificond"); 38 EXPECT_TRUE(WaitForTrue(WificondIsDead, 39 ScopedDevModeWificond::kWificondDeathTimeoutSeconds)); 40 41 // Confirm that the service manager has no binder for wificond. 42 EXPECT_FALSE(IsBinderServiceRegistered(kServiceName)); 43 44 // Start wificond. 45 RunShellCommand("start wificond"); 46 EXPECT_TRUE(WaitForTrue(WificondIsRunning, 47 ScopedDevModeWificond::kWificondStartTimeoutSeconds)); 48 49 // wificond should eventually register with the service manager. 50 EXPECT_TRUE(WaitForTrue(std::bind(IsBinderServiceRegistered, kServiceName), 51 ScopedDevModeWificond::kWificondStartTimeoutSeconds)); 52 } 53 54 } // namespace wificond 55 } // namespace android 56