17115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley/*
27115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * Copyright (C) 2016, The Android Open Source Project
37115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley *
47115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * Licensed under the Apache License, Version 2.0 (the "License");
57115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * you may not use this file except in compliance with the License.
67115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * You may obtain a copy of the License at
77115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley *
87115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley *     http://www.apache.org/licenses/LICENSE-2.0
97115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley *
107115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * Unless required by applicable law or agreed to in writing, software
117115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * distributed under the License is distributed on an "AS IS" BASIS,
127115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * See the License for the specific language governing permissions and
147115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley * limitations under the License.
157115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley */
167115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley
177115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley#include <gtest/gtest.h>
187115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley
19808c670699b218f8cc16f83e81be408ae441d44aNingyuan Wang#include "wificond/ipc_constants.h"
20808c670699b218f8cc16f83e81be408ae441d44aNingyuan Wang#include "wificond/tests/shell_utils.h"
21c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wiley#include "wificond/tests/integration/process_utils.h"
227115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley
235e18d224c8d97ce2d3862ce971a2e94f7bdf7a84Christopher Wileyusing android::wificond::ipc_constants::kServiceName;
247115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wileyusing android::wificond::tests::integration::RunShellCommand;
25c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wileyusing android::wificond::tests::integration::WaitForTrue;
26c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wileyusing android::wificond::tests::integration::IsBinderServiceRegistered;
27c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wileyusing android::wificond::tests::integration::ScopedDevModeWificond;
28c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wileyusing android::wificond::tests::integration::WificondIsRunning;
29c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wileyusing android::wificond::tests::integration::WificondIsDead;
30c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wileyusing android::wificond::tests::integration::WificondSetDevMode;
317115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley
327115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wileynamespace android {
337115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wileynamespace wificond {
347115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley
357115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher WileyTEST(LifeCycleTest, ProcessStartsUp) {
367115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley  // Request that wificond be stopped (regardless of its current state).
377115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley  RunShellCommand("stop wificond");
38c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wiley  EXPECT_TRUE(WaitForTrue(WificondIsDead,
39c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wiley                          ScopedDevModeWificond::kWificondDeathTimeoutSeconds));
407115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley
41f3116b3d898be88ef7cc087cd7a402559b7e700cChristopher Wiley  // Confirm that the service manager has no binder for wificond.
42c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wiley  EXPECT_FALSE(IsBinderServiceRegistered(kServiceName));
437115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley
447115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley  // Start wificond.
457115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley  RunShellCommand("start wificond");
46c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wiley  EXPECT_TRUE(WaitForTrue(WificondIsRunning,
47c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wiley                          ScopedDevModeWificond::kWificondStartTimeoutSeconds));
48f3116b3d898be88ef7cc087cd7a402559b7e700cChristopher Wiley
49f3116b3d898be88ef7cc087cd7a402559b7e700cChristopher Wiley  // wificond should eventually register with the service manager.
50c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wiley  EXPECT_TRUE(WaitForTrue(std::bind(IsBinderServiceRegistered, kServiceName),
51c5f37c05c57b56fc0a5709075e2b32ab6115b5acChristopher Wiley                          ScopedDevModeWificond::kWificondStartTimeoutSeconds));
527115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley}
537115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley
547115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley}  // namespace wificond
557115928cf880f8d197ecd4aaa1d9e64c209b8704Christopher Wiley}  // namespace android
56