<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>apps/media/scripts/user.js</filename>
    </added>
    <added>
      <filename>tests</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,21 +1,13 @@
-function createService(type) {
-    type = type || 'jquery';
-
-    if (type == 'gears') {
-        gearsHandler.proxyUrl = location.protocol + '//' + location.host + '/proxy?url=',
-        gearsHandler.workerUrl = location.protocol + '//' + location.host + '/media/scripts/worker.js',
-        $.douban.http.register('gears', gearsHandler);
-    }
-
-    var service = $.douban('service', {
+function createService() {
+    var service = Douban({
         key: '0107c5c3c9d4ecc40317514b5d7ec64c',
         secret: '7feaf4ec7b6989f8',
-        type: type
+        type: Douban.handler.jquery
     });
 
     service.login({
-        key: 'c002c5818edc6c1340085084ac954439',
-        secret: '4687aa78ddedf5f6'
+        key: '2e2fa5e45bee84308a8ef1ad13cb8c90',
+        secret: 'fe5e5256ee3128a1'
     });
     return service;
 }</diff>
      <filename>apps/media/tests/base.js</filename>
    </modified>
    <modified>
      <diff>@@ -46,11 +46,10 @@ test(&quot;test authorization step 3: get access token&quot;, function() {
         secret: '7feaf4ec7b6989f8'
     });
     requestToken = {
-        key: '40124b62c57031c6c036e22850509552',
-        secret: '4fb86fde66ae75c0'
+        key: '88d04025e89c77bb9a70c071b9d56731',
+        secret: '21916217444e9509'
     };
 
-    /*
     stop();
     client.accessToken(requestToken, function(token, uid) {
         // When the client is authenticated, the request token will be invalid
@@ -61,7 +60,6 @@ test(&quot;test authorization step 3: get access token&quot;, function() {
         equals(uid, '2133418', &quot;get username&quot;);
         start();
     });
-    */
 });
 
 test(&quot;test programmatic login&quot;, function() {</diff>
      <filename>apps/media/tests/oauth.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,71 +1,80 @@
 module(&quot;Douban User Testcases&quot;);
 
-test(&quot;test user api&quot;, function() {
-    expect(21);
-
+test(&quot;test get user profile&quot;, function() {
     if (typeof netscape != 'undefined')
         netscape.security.PrivilegeManager.enablePrivilege(&quot;UniversalBrowserRead&quot;);
     var service = createService();
 
-    // get user profile
-    var ahbei = service.user.get('ahbei');
-    equals(ahbei.id, &quot;http://api.douban.com/people/1000001&quot;, &quot;get user id ok&quot;);
-    equals(ahbei.userName, &quot;ahbei&quot;, &quot;get user name ok&quot;);
-    equals(ahbei.screenName, &quot;&#38463;&#21271;&quot;, &quot;get screen name ok&quot;);
-    equals(ahbei.location, &quot;&#21271;&#20140;&quot;, &quot;get location ok&quot;);
-    equals(ahbei.blog, &quot;http://ahbei.com/&quot;, &quot;get blog ok&quot;);
-    equals(ahbei.intro, &quot;&#35910;&#29923;&#30340;&#20020;&#26102;&#24635;&#31649;&#12290;&#29616;&#22312;&#22810;&#25968;&#26102;&#38388;&#22312;&#24537;&#24537;&#30860;&#30860;&#22320;&#20026;&#35910;&#29923;&#28155;&#30742;&#21152;&#29926;&#12290;&#22352;&#22312;&#39532;&#26742;&#19978;&#30475;&#20070;&#65292;&#31639;&#26159;&#19968;&#22825;&#20013;&#26368;&#25918;&#26494;&#30340;&#26102;&#38388;&#12290;\r\n\r\n&#25105;&#19981;&#20294;&#21916;&#27426;&#35835;&#20070;&#12289;&#26053;&#34892;&#21644;&#38899;&#20048;&#30005;&#24433;&#65292;&#36824;&#26366;&#32463;&#26159;&#19968;&#20010;&#20048;&#27492;&#19981;&#30130;&#30340;&#23454;&#36341;&#32773;&#65292;&#26377;&#19968;&#22681;&#30879;&#12289;&#20004;&#22681;&#20070;&#12289;&#19977;&#22823;&#27954;&#30340;&#36710;&#33337;&#31080;&#20026;&#35760;&#12290;&#29616;&#22312;&#33258;&#24049;&#28216;&#33633;&#24046;&#19981;&#22810;&#22815;&#20102;&#65292;&#24320;&#22987;&#25026;&#24471;&#20998;&#20139;&#21644;&#22238;&#39304;&#12290;&#35910;&#29923;&#26159;&#19968;&#20010;&#24320;&#22987;&#65292;&#24076;&#26395;&#23427;&#23545;&#20320;&#21516;&#26679;&#26377;&#29992;&#12290;\r\n\r\n(&#25105;&#30340;&#26379;&#21451;&#36992;&#35831;&#21407;&#21017;&#65306;&#19968;&#33324;&#26159;&#32447;&#19979;&#26379;&#21451;&#65292;&#35265;&#36807;&#19981;&#21482;&#19968;&#27425;&#38754;&#12290;&#35874;&#35874;&#8220;&#20851;&#27880;&#8221; )&#12290;\r\n&quot;, &quot;get introduction ok&quot;);
-    equals(ahbei.url, &quot;http://www.douban.com/people/ahbei/&quot;, &quot;get user url ok&quot;);
-    equals(ahbei.imageUrl, &quot;http://otho.douban.com/icon/u1000001-14.jpg&quot;, &quot;get user icon url ok&quot;);
+    stop();
+    service.user.get('ahbei', function(ahbei) {
+        console.debug(ahbei);
+        equals(ahbei.id, &quot;http://api.douban.com/people/1000001&quot;, &quot;get user id ok&quot;);
+        equals(ahbei.uid, &quot;ahbei&quot;, &quot;get user name ok&quot;);
+        equals(ahbei.name, &quot;&#38463;&#21271;&quot;, &quot;get screen name ok&quot;);
+        equals(ahbei.location, &quot;&#21271;&#20140;&quot;, &quot;get location ok&quot;);
+        equals(ahbei.link.blog, &quot;http://ahbei.com/&quot;, &quot;get blog ok&quot;);
+        equals(ahbei.intro, &quot;&#35910;&#29923;&#30340;&#20020;&#26102;&#24635;&#31649;&#12290;&#29616;&#22312;&#22810;&#25968;&#26102;&#38388;&#22312;&#24537;&#24537;&#30860;&#30860;&#22320;&#20026;&#35910;&#29923;&#28155;&#30742;&#21152;&#29926;&#12290;&#22352;&#22312;&#39532;&#26742;&#19978;&#30475;&#20070;&#65292;&#31639;&#26159;&#19968;&#22825;&#20013;&#26368;&#25918;&#26494;&#30340;&#26102;&#38388;&#12290;\r\n\r\n&#25105;&#19981;&#20294;&#21916;&#27426;&#35835;&#20070;&#12289;&#26053;&#34892;&#21644;&#38899;&#20048;&#30005;&#24433;&#65292;&#36824;&#26366;&#32463;&#26159;&#19968;&#20010;&#20048;&#27492;&#19981;&#30130;&#30340;&#23454;&#36341;&#32773;&#65292;&#26377;&#19968;&#22681;&#30879;&#12289;&#20004;&#22681;&#20070;&#12289;&#19977;&#22823;&#27954;&#30340;&#36710;&#33337;&#31080;&#20026;&#35760;&#12290;&#29616;&#22312;&#33258;&#24049;&#28216;&#33633;&#24046;&#19981;&#22810;&#22815;&#20102;&#65292;&#24320;&#22987;&#25026;&#24471;&#20998;&#20139;&#21644;&#22238;&#39304;&#12290;&#35910;&#29923;&#26159;&#19968;&#20010;&#24320;&#22987;&#65292;&#24076;&#26395;&#23427;&#23545;&#20320;&#21516;&#26679;&#26377;&#29992;&#12290;\r\n\r\n(&#25105;&#30340;&#26379;&#21451;&#36992;&#35831;&#21407;&#21017;&#65306;&#19968;&#33324;&#26159;&#32447;&#19979;&#26379;&#21451;&#65292;&#35265;&#36807;&#19981;&#21482;&#19968;&#27425;&#38754;&#12290;&#35874;&#35874;&#8220;&#20851;&#27880;&#8221; )&#12290;\r\n&quot;, &quot;get introduction ok&quot;);
+        equals(ahbei.link.home, &quot;http://www.douban.com/people/ahbei/&quot;, &quot;get user url ok&quot;);
+        equals(ahbei.link.image, &quot;http://otho.douban.com/icon/u1000001-14.jpg&quot;, &quot;get user icon url ok&quot;);
+        start();
+    });
+});
 
-    // get user's friends
-    var friends = service.user.friends('wyt', 7, 4);
-    ok(friends.total &gt; 72, &quot;get user's total friends ok&quot;);
-    equals(friends.entries.length, 4, &quot;get user's friends ok&quot;);
+test(&quot;test get user friends&quot;, function() {
+    if (typeof netscape != 'undefined')
+        netscape.security.PrivilegeManager.enablePrivilege(&quot;UniversalBrowserRead&quot;);
+    var service = createService();
 
-    // get user's contacts
-    var contacts = service.user.contacts('wyt', 2, 5);
-    ok(contacts.total &gt; 111);
-    equals(contacts.entries.length, 5, &quot;get user's contacts ok&quot;);
+    stop();
+    service.user.friends('wyt', 7, 4, function(friends) {
+        console.debug(friends);
+        ok(friends.total &gt; 72, &quot;get user's total friends ok&quot;);
+        equals(friends.entry.length, 4, &quot;get user's friends ok&quot;);
+        start();
+    });
+});
 
-    // get current authenticated user
-    var me = service.user.current();
-    equals(me.id, &quot;http://api.douban.com/people/2133418&quot;, &quot;get current user name ok&quot;);
-    equals(me.userName, &quot;iloveshutuo&quot;, &quot;get current user id ok&quot;);
+test(&quot;test get user contacts&quot;, function() {
+    if (typeof netscape != 'undefined')
+        netscape.security.PrivilegeManager.enablePrivilege(&quot;UniversalBrowserRead&quot;);
+    var service = createService();
 
-    // search people
-    var result = service.user.search('ke', 6, 3);
-    ok(result.total, &quot;okay: search people total results is&quot; + result.total);
-    equals(result.offset, 6, &quot;search people start index ok&quot;);
-    equals(result.limit, 3, &quot;search people max results ok&quot;);
-    equals(result.entries.length, 3, &quot;search people ok&quot;);
-    equals(result.entries[0].id, &quot;http://api.douban.com/people/1110946&quot;, &quot;get user id ok&quot;);
-    equals(result.entries[1].id, &quot;http://api.douban.com/people/1652131&quot;, &quot;get user id ok&quot;);
-    equals(result.entries[2].id, &quot;http://api.douban.com/people/1280023&quot;, &quot;get user id ok&quot;);
+    stop();
+    service.user.contacts('wyt', 2, 5, function(contacts) {
+        ok(contacts.total &gt; 111);
+        equals(contacts.entry.length, 5, &quot;get user's contacts ok&quot;);
+        start();
+    });
 });
 
-test(&quot;test user object&quot;, function() {
-    expect(15);
-
-    var json = {&quot;content&quot;:{&quot;$t&quot;:&quot;&quot;},&quot;db:uid&quot;:{&quot;$t&quot;:&quot;whoami&quot;},&quot;link&quot;:[{&quot;@rel&quot;:&quot;self&quot;,&quot;@href&quot;:&quot;http://api.douban.com/people/2139418&quot;},{&quot;@rel&quot;:&quot;alternate&quot;,&quot;@href&quot;:&quot;http://www.douban.com/people/whoami/&quot;},{&quot;@rel&quot;:&quot;icon&quot;,&quot;@href&quot;:&quot;http://otho.douban.com/icon/u2139418-1.jpg&quot;}],&quot;id&quot;:{&quot;$t&quot;:&quot;http://api.douban.com/people/2139418&quot;},&quot;title&quot;:{&quot;$t&quot;:&quot;&#25105;&#26159;&#35841;&quot;}};
-    var user = $.douban('user', json);
-    equals(user.id, &quot;http://api.douban.com/people/2139418&quot;, &quot;get user id ok&quot;);
-    equals(user.userName, &quot;whoami&quot;, &quot;get user name ok&quot;);
-    equals(user.screenName, &quot;&#25105;&#26159;&#35841;&quot;, &quot;get screen name ok&quot;);
-    equals(user.location, undefined, &quot;get user location ok&quot;);
-    equals(user.blog, undefined, &quot;get user blog ok&quot;);
-    equals(user.intro, '', &quot;get user introduction ok&quot;);
-    equals(user.url, &quot;http://www.douban.com/people/whoami/&quot;, &quot;get user homepage ok&quot;);
-    equals(user.imageUrl, &quot;http://otho.douban.com/icon/u2139418-1.jpg&quot;, &quot;get user icon url ok&quot;);
+test(&quot;test get current authenticated user&quot;, function() {
+    if (typeof netscape != 'undefined')
+        netscape.security.PrivilegeManager.enablePrivilege(&quot;UniversalBrowserRead&quot;);
+    var service = createService();
 
-    var user2 = $.douban('user');
-    equals(user2.id, undefined);
-    equals(user2.userName, undefined);
-    equals(user2.location, undefined);
-    equals(user2.blog, undefined);
-    equals(user2.intro, undefined);
-    equals(user2.url, undefined);
-    equals(user2.imageUrl, undefined);
+    stop();
+    service.user.current(function(me) {
+        equals(me.id, &quot;http://api.douban.com/people/2133418&quot;, &quot;get current user name ok&quot;);
+        equals(me.uid, &quot;iloveshutuo&quot;, &quot;get current user id ok&quot;);
+        start();
+    });
 });
 
-// vim: foldmethod=indent
+test(&quot;test search people&quot;, function() {
+    if (typeof netscape != 'undefined')
+        netscape.security.PrivilegeManager.enablePrivilege(&quot;UniversalBrowserRead&quot;);
+    var service = createService();
+    var re = /^http:\/\/api\.douban\.com\/people\/\d+$/;
+
+    stop();
+    service.user.search('ke', 2, 3, function(result) {
+        ok(result.total, &quot;okay: search people total results is &quot; + result.total);
+        equals(result.offset, 2, &quot;search people start index ok&quot;);
+        equals(result.limit, 3, &quot;search people max results ok&quot;);
+        equals(result.entry.length, 3, &quot;search people ok&quot;);
+        ok(result.entry[0].id.match(re), &quot;get user id ok&quot;);
+        ok(result.entry[1].id.match(re), &quot;get user id ok&quot;);
+        ok(result.entry[2].id.match(re), &quot;get user id ok&quot;);
+        start();
+    });
+});</diff>
      <filename>apps/media/tests/user.js</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1,12 @@
 {% extends 'base.html' %}
+
+{% block js %}
+&lt;script type=&quot;text/javascript&quot; src=&quot;/media/scripts/sha1.js&quot; &gt;&lt;/script&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;/media/scripts/oauth.js&quot; &gt;&lt;/script&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;/media/scripts/core.js&quot; &gt;&lt;/script&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;/media/scripts/utils.js&quot; &gt;&lt;/script&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;/media/scripts/client.js&quot; &gt;&lt;/script&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;/media/scripts/parser.js&quot; &gt;&lt;/script&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;/media/scripts/user.js&quot; &gt;&lt;/script&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;/media/scripts/jquery_handler.js&quot; &gt;&lt;/script&gt;
+{% endblock %}</diff>
      <filename>apps/templates/tests/user.html</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1cc7a00592c701702674736278d1e2960f4d04b0</id>
    </parent>
  </parents>
  <author>
    <name>wu yuntao</name>
    <email>wyt.py@thonic.org</email>
  </author>
  <url>http://github.com/wuyuntao/jquery-douban/commit/12f3db2608499edec41f86afeeac106cedc5d21d</url>
  <id>12f3db2608499edec41f86afeeac106cedc5d21d</id>
  <committed-date>2009-03-18T03:22:20-07:00</committed-date>
  <authored-date>2009-03-18T03:22:20-07:00</authored-date>
  <message>User api testcases</message>
  <tree>f11a5a3497780c253ea53624613a6f54ea39443d</tree>
  <committer>
    <name>wu yuntao</name>
    <email>wyt.py@thonic.org</email>
  </committer>
</commit>
