Upstream version 9.38.204.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / test / application_testapi_test.cc
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/public/test/browser_test_utils.h"
6 #include "net/base/net_util.h"
7 #include "xwalk/application/test/application_browsertest.h"
8 #include "xwalk/application/test/application_testapi.h"
9
10 using xwalk::application::Application;
11
12 class ApplicationTestApiTest : public ApplicationBrowserTest {
13 };
14
15 IN_PROC_BROWSER_TEST_F(ApplicationTestApiTest, TestApiTest) {
16   Application* app = application_sevice()->LaunchFromUnpackedPath(
17       test_data_dir_.Append(FILE_PATH_LITERAL("testapi")));
18   ASSERT_TRUE(app);
19   test_runner_->WaitForTestNotification();
20   EXPECT_EQ(test_runner_->GetTestsResult(), ApiTestRunner::FAILURE);
21
22   test_runner_->PostResultToNotificationCallback();
23   test_runner_->WaitForTestNotification();
24   EXPECT_EQ(test_runner_->GetTestsResult(), ApiTestRunner::PASS);
25
26   test_runner_->PostResultToNotificationCallback();
27   test_runner_->WaitForTestNotification();
28   EXPECT_EQ(test_runner_->GetTestsResult(), ApiTestRunner::TIMEOUT);
29
30   // xwalk.app.test.runTest will notify pass when all tests are finished.
31   test_runner_->PostResultToNotificationCallback();
32   test_runner_->WaitForTestNotification();
33   EXPECT_EQ(test_runner_->GetTestsResult(), ApiTestRunner::PASS);
34 }