gstreamer_core/tsrc/check/gst/gstsegment/src/gstsegment.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
     1  /*
     1 /*
     2  *  Copyright © 2008 Nokia Corporation.
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     3  *  This material, including documentation and any related 
     3 *
     4  *  computer programs, is protected by copyright controlled by 
     4 * This library is free software; you can redistribute it and/or
     5  *  Nokia Corporation. All rights are reserved. Copying, 
     5 * modify it under the terms of the GNU Lesser General Public
     6  *  including reproducing, storing, adapting or translating, any 
     6 * License as published by the Free Software Foundation; either
     7  *  or all of this material requires the prior written consent of 
     7 * version 2 of the License, or (at your option) any later version.
     8  *  Nokia Corporation. This material also contains confidential 
     8 *
     9  *  information which may not be disclosed to others without the 
     9 * This library is distributed in the hope that it will be useful,
    10  *  prior written consent of Nokia Corporation.
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * ============================================================================
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    12  */
    12 * Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public
       
    15 * License along with this library; if not, write to the
       
    16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    17 * Boston, MA 02111-1307, USA.
       
    18 *
       
    19 * Description:
       
    20 *
       
    21 */
    13  
    22  
    14 /* GStreamer
    23 /* GStreamer
    15  * Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com>
    24  * Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com>
    16  *
    25  *
    17  * gstsegment.c: Unit test for segments
    26  * gstsegment.c: Unit test for segments
    43 
    52 
    44 #if EMULATOR
    53 #if EMULATOR
    45 static GET_GLOBAL_VAR_FROM_TLS(raised_critical,gstcheck,gboolean)
    54 static GET_GLOBAL_VAR_FROM_TLS(raised_critical,gstcheck,gboolean)
    46 #define _gst_check_raised_critical (*GET_GSTREAMER_WSD_VAR_NAME(raised_critical,gstcheck,g)())
    55 #define _gst_check_raised_critical (*GET_GSTREAMER_WSD_VAR_NAME(raised_critical,gstcheck,g)())
    47 #else 
    56 #else 
    48 IMPORT_C extern gboolean _gst_check_raised_critical;
    57 extern gboolean _gst_check_raised_critical;
    49 #endif
    58 #endif
    50 
    59 
    51 //gboolean _gst_check_expecting_log = FALSE;
    60 //gboolean _gst_check_expecting_log = FALSE;
    52 #if EMULATOR
    61 #if EMULATOR
    53 static GET_GLOBAL_VAR_FROM_TLS(expecting_log,gstcheck,gboolean)
    62 static GET_GLOBAL_VAR_FROM_TLS(expecting_log,gstcheck,gboolean)
    54 #define _gst_check_expecting_log (*GET_GSTREAMER_WSD_VAR_NAME(expecting_log,gstcheck,g)())
    63 #define _gst_check_expecting_log (*GET_GSTREAMER_WSD_VAR_NAME(expecting_log,gstcheck,g)())
    55 #else 
    64 #else 
    56 IMPORT_C extern gboolean _gst_check_expecting_log;
    65 extern gboolean _gst_check_expecting_log;
    57 #endif
    66 #endif
    58 
    67 
    59 
    68 
    60 //char* xmlfile = "gstsegment";
    69 //char* xmlfile = "gstsegment";
    61 
    70 
    62 void create_xml(int result)
    71 void create_xml(int result)
    63 {
    72 {
    64 
       
    65     if(result)
    73     if(result)
    66     {
       
    67         assert_failed = 1;
    74         assert_failed = 1;
    68     } 
    75     
    69 
       
    70     testResultXml(xmlfile);
    76     testResultXml(xmlfile);
    71     close_log_file();
    77     close_log_file();
    72 
       
    73     if(result)
       
    74     {
       
    75         exit (-1);
       
    76     }    
       
    77 
       
    78 }
    78 }
    79 
    79 
    80 void segment_seek_nosize()
    80 void segment_seek_nosize()
    81 {
    81 {
    82   GstSegment segment;
    82   GstSegment segment;
  1593   fail_unless (segment.time == 200);
  1593   fail_unless (segment.time == 200);
  1594   
  1594   
  1595   /* accumulated 100 of previous segment to make 200 */
  1595   /* accumulated 100 of previous segment to make 200 */
  1596   fail_unless (segment.accum == 200);
  1596   fail_unless (segment.accum == 200);
  1597   
  1597   
  1598   fail_unless (segment.last_stop == 200);
  1598   fail_unless (segment.last_stop == 0);
  1599   
  1599   
  1600   fail_unless (segment.duration == -1);
  1600   fail_unless (segment.duration == -1);
  1601   
  1601   
  1602 
  1602 
  1603   /* invalid time gives invalid result */
  1603   /* invalid time gives invalid result */
  1649   
  1649   
  1650   fail_unless (segment.time == 0);
  1650   fail_unless (segment.time == 0);
  1651   
  1651   
  1652   fail_unless (segment.accum == 400);
  1652   fail_unless (segment.accum == 400);
  1653   
  1653   
  1654   fail_unless (segment.last_stop == 200);
  1654   fail_unless (segment.last_stop == 0);
  1655   
  1655   
  1656   fail_unless (segment.duration == -1);
  1656   fail_unless (segment.duration == -1);
  1657   
  1657   
  1658 
  1658 
  1659   /* invalid time gives invalid result */
  1659   /* invalid time gives invalid result */
  1942   
  1942   
  1943   fail_unless (segment.time == 0);
  1943   fail_unless (segment.time == 0);
  1944   
  1944   
  1945   fail_unless (segment.accum == 0);
  1945   fail_unless (segment.accum == 0);
  1946   
  1946   
  1947   fail_unless (segment.last_stop == 200);
  1947   fail_unless (segment.last_stop == 0);
  1948   
  1948   
  1949   fail_unless (segment.duration == -1);
  1949   fail_unless (segment.duration == -1);
  1950   
  1950   
  1951 
  1951 
  1952   /* invalid time gives invalid result */
  1952   /* invalid time gives invalid result */
  1980   
  1980   
  1981   fail_unless (segment.time == 0);
  1981   fail_unless (segment.time == 0);
  1982   
  1982   
  1983   fail_unless (segment.accum == 50);
  1983   fail_unless (segment.accum == 50);
  1984   
  1984   
  1985   fail_unless (segment.last_stop == 150);
  1985   fail_unless (segment.last_stop == 0);
  1986   
  1986   
  1987   fail_unless (segment.duration == -1);
  1987   fail_unless (segment.duration == -1);
  1988   
  1988   
  1989 
  1989 
  1990   result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 150);
  1990   result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 150);
  2014   
  2014   
  2015   fail_unless (segment.time == 100);
  2015   fail_unless (segment.time == 100);
  2016   
  2016   
  2017   fail_unless (segment.accum == 50);
  2017   fail_unless (segment.accum == 50);
  2018   
  2018   
  2019   fail_unless (segment.last_stop == 150);
  2019   fail_unless (segment.last_stop == 100);
  2020   
  2020   
  2021   fail_unless (segment.duration == -1);
  2021   fail_unless (segment.duration == -1);
  2022   
  2022   
  2023 
  2023 
  2024   result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100);
  2024   result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100);
  2065   
  2065   
  2066   fail_unless (segment.time == 0);
  2066   fail_unless (segment.time == 0);
  2067   
  2067   
  2068   fail_unless (segment.accum == 0);
  2068   fail_unless (segment.accum == 0);
  2069   
  2069   
  2070   fail_unless (segment.last_stop == 200);
  2070   fail_unless (segment.last_stop == 0);
  2071   
  2071   
  2072   fail_unless (segment.duration == -1);
  2072   fail_unless (segment.duration == -1);
  2073   
  2073   
  2074 
  2074 
  2075   /* invalid time gives invalid result */
  2075   /* invalid time gives invalid result */
  2103   
  2103   
  2104   fail_unless (segment.time == 0);
  2104   fail_unless (segment.time == 0);
  2105   
  2105   
  2106   fail_unless (segment.accum == 0);
  2106   fail_unless (segment.accum == 0);
  2107   
  2107   
  2108   fail_unless (segment.last_stop == 200);
  2108   fail_unless (segment.last_stop == 150);
  2109   
  2109   
  2110   fail_unless (segment.duration == -1);
  2110   fail_unless (segment.duration == -1);
  2111   
  2111   
  2112 
  2112 
  2113   /* new segment, this accumulates 50. */
  2113   /* new segment, this accumulates 50. */