Saving a bit of memory by using pretty function instead of full file name
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Stage.cpp
index 7a94312..0f850e3 100644 (file)
@@ -1,31 +1,32 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 #include <iostream>
 
 #include <stdlib.h>
 
-#include <dali/dali.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/context-notifier.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 
 #include <dali-test-suite-utils.h>
 
 using namespace Dali;
-using namespace std;
 
 void stage_test_startup(void)
 {
@@ -134,6 +135,26 @@ bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
   return true;
 }
 
+
+struct ContextStatusFunctor
+{
+  ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
+  {
+    mCalledFlag = false;
+  }
+
+  void operator()()
+  {
+    mCalledFlag = true;
+  }
+  void Reset()
+  {
+    mCalledFlag = false;
+  }
+
+  bool& mCalledFlag;
+};
+
 } // unnamed namespace
 
 
@@ -594,3 +615,26 @@ int UtcDaliStageTouchedSignal(void)
   }
   END_TEST;
 }
+
+int UtcDaliStageContextLostRegainedSignals(void)
+{
+  TestApplication app;
+  Stage stage = Stage::GetCurrent();
+
+  bool contextLost = false;
+  bool contextRegained = false;
+  ContextStatusFunctor contextLostFunctor( contextLost );
+  ContextStatusFunctor contextRegainedFunctor( contextRegained );
+  stage.ContextLostSignal().Connect(&app, contextLostFunctor );
+  stage.ContextRegainedSignal().Connect(&app, contextRegainedFunctor );
+
+  Integration::Core& core = app.GetCore();
+  Integration::ContextNotifierInterface* notifier = core.GetContextNotifier();
+  notifier->NotifyContextLost();
+  DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
+
+  notifier->NotifyContextRegained();
+  DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
+
+  END_TEST;
+}