gstreamer_core/tsrc/check/gst/gstsegment/src/gstsegment.c
changeset 8 4a7fac7dd34a
parent 2 5505e8908944
child 9 2a0f36a70380
equal deleted inserted replaced
7:71e347f905f2 8:4a7fac7dd34a
     1 /*
     1  /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     2  *  Copyright © 2008 Nokia Corporation.
     3 *
     3  *  This material, including documentation and any related 
     4 * This library is free software; you can redistribute it and/or
     4  *  computer programs, is protected by copyright controlled by 
     5 * modify it under the terms of the GNU Lesser General Public
     5  *  Nokia Corporation. All rights are reserved. Copying, 
     6 * License as published by the Free Software Foundation; either
     6  *  including reproducing, storing, adapting or translating, any 
     7 * version 2 of the License, or (at your option) any later version.
     7  *  or all of this material requires the prior written consent of 
     8 *
     8  *  Nokia Corporation. This material also contains confidential 
     9 * This library is distributed in the hope that it will be useful,
     9  *  information which may not be disclosed to others without the 
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  *  prior written consent of Nokia Corporation.
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    11  * ============================================================================
    12 * Lesser General Public License for more details.
    12  */
    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 */
       
    22  
    13  
    23 /* GStreamer
    14 /* GStreamer
    24  * Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com>
    15  * Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com>
    25  *
    16  *
    26  * gstsegment.c: Unit test for segments
    17  * gstsegment.c: Unit test for segments
    68 
    59 
    69 //char* xmlfile = "gstsegment";
    60 //char* xmlfile = "gstsegment";
    70 
    61 
    71 void create_xml(int result)
    62 void create_xml(int result)
    72 {
    63 {
       
    64 
    73     if(result)
    65     if(result)
       
    66     {
    74         assert_failed = 1;
    67         assert_failed = 1;
    75     
    68     } 
       
    69 
    76     testResultXml(xmlfile);
    70     testResultXml(xmlfile);
    77     close_log_file();
    71     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 == 0);
  1598   fail_unless (segment.last_stop == 200);
  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 == 0);
  1654   fail_unless (segment.last_stop == 200);
  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 == 0);
  1947   fail_unless (segment.last_stop == 200);
  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 == 0);
  1985   fail_unless (segment.last_stop == 150);
  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 == 100);
  2019   fail_unless (segment.last_stop == 150);
  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 == 0);
  2070   fail_unless (segment.last_stop == 200);
  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 == 150);
  2108   fail_unless (segment.last_stop == 200);
  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. */